2

I use python3.5.2 and PyQt4.

Im using PyQt to connect and use .ocx.

from PyQt4.QAxContainer import QAxWidget
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        while True:
            # run some codes that use QAxWidget.dynamicCall() function
            # print some results
            sleep(30)

After sleep and going back to main code, i got "Process finished with exit code -1073740771 (0xC000041D)"

I tried to use try... except... clause, but could not catch error.

What problems should I speculate?

How can I debug?

EDIT:

crash report:

program name: python.exe, version: 3.5.1150.1013, timestamp: 0x576eff6a

module name: QAxContainer.pyd, version: 0.0.0.0, timestamp: 0x56123368

exception code: 0xc000041d

error offset: 0x00013301

process ID: 0x4d24

EDIT2:

If I set the sleep(30) to sleep(10), it works correctly without any crash.

SounBum Song
  • 225
  • 1
  • 3
  • 11
  • 1
    http://stackoverflow.com/questions/11945183/what-are-good-practices-for-avoiding-crashes-hangs-in-pyqt?rq=1 – eshwar m Nov 07 '16 at 06:07
  • 1
    I suppose the problem is, that if you use `time.sleep(30)`, your program stays unresponsive for half a minute, such that Windows suspects it to have crashed and terminates the process. Why is this sleep necessary? A good rule of thumb is the following: **Never use `time.sleep()` in a pyqt application.** – ImportanceOfBeingErnest Nov 10 '16 at 08:17

1 Answers1

0

I can be the garbage collector that dispose your app.
So try putting the app global.

Try in this way:

from PyQt4.QAxContainer import QAxWidget
app = None

if __name__ == "__main__":
    app = QApplication(sys.argv)
    while True:
        # run some codes that use QAxWidget.dynamicCall() function
        # print some results
        sleep(30)
Davide Pizzolato
  • 679
  • 8
  • 25