May 2, 2023, 5:08 p.m. | C. Plug

DEV Community dev.to




TL;DR


Use faulthandler.enable(); Python will print the stack trace to stderr before fully crashing.





Backstory


Today I tried to daemonize a Python script that calls request.get on macOS, and it was insta-dying for no apparent reason.

I tested without daemonization, but the problem only popped up when I daemonize it.


I was doing something like this:



from daemon import DaemonContext
from daemon.pidfile import PIDLockFile
import requests
import time


pid = PIDLockFile(path.join(home_dir, 'pidfile_watcher' …

debug macos python python script stack

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

#13721 - Data Engineer - AI Model Testing

@ Qualitest | Miami, Florida, United States

Elasticsearch Administrator

@ ManTech | 201BF - Customer Site, Chantilly, VA