簡體   English   中英

Python腳本停止出現BEX錯誤

[英]Python script stops working with BEX error

我有一個在Windows上運行的Python腳本,該腳本基本上是具有SQL數據庫的多個連接的RESTful接口客戶端。 它必須重新啟動一段時間(例如15分鍾)。 為此,我使用os.execl()函數將代碼包裝在循環中。 我使用以下格式從PowerShell運行腳本:

PS C:\test> python.exe .\script.pyc

腳本本身(不公開實現細節):

import base64
import datetime
import glob
import logging
import os
import socket
import sys
import threading
import time
import pyodbc
import binascii
import configparser
import codecs
import requests
from collections import namedtuple
from binascii import unhexlify, b2a_base64

FORMAT = '%(asctime)-15s %(levelname)-10s %(message)s'
logging.basicConfig(format=FORMAT, level=logging.INFO)
log = logging.getLogger()

# some class declarations here

if __name__ == '__main__':

    # Initializing counter for time
    timeLast = time.time()

    while 1:
        timeCurrent = time.time()
        if ((timeCurrent - timeLast) > resetTime):
            timeLast = timeCurrent
            os.execl(sys.executable, sys.executable, * sys.argv)

        try:        
            # Fetching data from DB
            # Processing data

        except Exception as e:
            log.error(repr(e))
            time.sleep(1)

# Wait for user input before exiting
sys.stdin.read()

但是,運行幾天后,腳本將停止處理以下緩沖區溢出異常(BEX):

錯誤的應用程序python.exe,版本3.6.3150.1013,時間戳0x59d3c90d,錯誤的模塊ucrtbase.dll,版本10.0.10586.1171,時間戳0x59ae5046,異常代碼0xc0000417,錯誤偏移量0x000834c4,進程ID 0xecc,應用程序啟動時間0x01d351c6613b826e。

另外,我注意到PowerShell控制台窗口不會刷新窗口內容,除非我將其窗口置於焦點上並向下按箭頭。 也許有些不同的問題。

環境:

  • Windows Server Standard SP2(32位)
  • PowerShell 2.0
  • Python 3.6.3

似乎問題與腳本在PowerShell中運行這一事實有關。 在Python Shell中運行腳本時未觀察到該錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM