繁体   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