简体   繁体   English

Python脚本停止出现BEX错误

[英]Python script stops working with BEX error

I have a Python script running on Windows, which is basically RESTful interface client with multiple connections to SQL database. 我有一个在Windows上运行的Python脚本,该脚本基本上是具有SQL数据库的多个连接的RESTful接口客户端。 It has to be restarted with some period of time (for example, 15 minutes). 它必须重新启动一段时间(例如15分钟)。 For this purpose I wrapped the code inside the loop with function os.execl() . 为此,我使用os.execl()函数将代码包装在循环中。 I run script from PowerShell using following format: 我使用以下格式从PowerShell运行脚本:

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

Script itself (without disclosing implementation details): 脚本本身(不公开实现细节):

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()

However, after few days of running script stops working with following buffer overflow exception (BEX): 但是,运行几天后,脚本将停止处理以下缓冲区溢出异常(BEX):

Faulting application python.exe, version 3.6.3150.1013, time stamp 0x59d3c90d, faulting module ucrtbase.dll, version 10.0.10586.1171, time stamp 0x59ae5046, exception code 0xc0000417, fault offset 0x000834c4, process id 0xecc, application start time 0x01d351c6613b826e. 错误的应用程序python.exe,版本3.6.3150.1013,时间戳0x59d3c90d,错误的模块ucrtbase.dll,版本10.0.10586.1171,时间戳0x59ae5046,异常代码0xc0000417,错误偏移量0x000834c4,进程ID 0xecc,应用程序启动时间0x01d351c6613b826e。

Also I noticed that PowerShell console window is not refreshing window content unless I put its window in focus and press arrow down. 另外,我注意到PowerShell控制台窗口不会刷新窗口内容,除非我将其窗口置于焦点上并向下按箭头。 Maybe some different issue. 也许有些不同的问题。

Environment: 环境:

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

Seems issue is related to that fact that script is running inside PowerShell. 似乎问题与脚本在PowerShell中运行这一事实有关。 It is not observed, while script is being run inside Python Shell. 在Python Shell中运行脚本时未观察到该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM