I have a python program that runs in a server continuously and it puts some data into MYSQL dataBase and load some. It is also using TCP/IP connection. the problem is that after about 24 hrs it gives a runtime error:
Microsoft Visual C++ Runtime Library!
Runtime Error!
Program: C:\python27\pythonw.exe
This application has requested the Runtime to terminate it in an unusual way.
And I hit OK python shell closes. And when I close all python files and check Windows Task Manager I see still there is a pythonw.exe file open there!!!
I am using IDLE to run my application.
Problem
If you ever receive this error while running a windows application, it is most possibly because somewhere in your python library, and even possible from your python runtime,
abort()
routine was called. For more information, and the behaviour of callingabort
please refer the MSDN documentation on abortDemo
You would need
Create a C DLL which calls
abort()
and then call this DLL using ctypesHeader File
abort_dll.h
Source
abort_dll.cpp
Source
dllmain.cpp
Now Compile and Build Your DLL (both in Debug and Release Version).
Assuming my DLLs are present in the following location
Debug Version: C:\TEMP\Debug\abort_dll.dll Release Version: C:\TEMP\Release\abort_dll.dll
Execute the following code in your IDLE
You are sure to see the following Popup
The only difference with your case is, it gives you the infamous option [Abort|Retry\Ignore]. It was only because I had used a Debug version of my DLL. Instead, if I had used a release version, I would typically see
Solution
In Windows, AFAIK you cannot handle the
SIGABRT
with a signal handler. So, the only bet is to use the JIT, that I suppose you had already installed. you would then see the following pop up.If you would select Debug, that will open your installed JIT debugger. After which, you can dump the failing stack, and determine the failing module. Once done, you can then correlate what could be the python module that might have called the module.
I was able to fix the same issue by eliminating the initiated, yet not displayed plots. It was:
I fix it for:
The error doesn't show up anymore.
In my former answer, I tried to introduce about the reason for the reported behavior and how one can debug and determine the root cause. Unfortunately, this requires an extensive debugging knowledge and time to isolate the problem.
Alternatively, Process Monitor can some handy to give a high level understanding of the problem, which as a User would post possibly need.
Tools Required
Steps to Debug
Add the following filters (Cntrl + F)
Search the LOG for a call to WerFault.exe
Gradually scroll up to see the last called Non Windows DLL which may be related to Python. In the above case, its abort_dll.dll.