Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug silent crashes? Multiprocessing python

I have a program that spawns a bunch of worker daemons using the multiprocessing library.

Sometimes these daemons will sporadically fall over and die. This isn't caused by a python-level Exception. The crashes seem to be totally silent...

Can anyone provide tips on how I may go about debugging this issue?


1 Answers

The faulthandler library might help debug such behavior. Run this code in every process run method to save tracebacks into separate files:

f = open('fault_%s.log' % multiprocessing.current_process().name, 'w')
faulthandler.enable(file=f, all_threads=True)
like image 200
Szymon Zmilczak Avatar answered Mar 21 '26 06:03

Szymon Zmilczak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!