简体   繁体   中英

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. It has to be restarted with some period of time (for example, 15 minutes). For this purpose I wrapped the code inside the loop with function os.execl() . I run script from PowerShell using following format:

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

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.

Also I noticed that PowerShell console window is not refreshing window content unless I put its window in focus and press arrow down. Maybe some different issue.

Environment:

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

Seems issue is related to that fact that script is running inside PowerShell. It is not observed, while script is being run inside Python Shell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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