I'd like to use logging.config.dictConfig
within my RQ worker. But, I found that after I run dictConfig()
, the worker will no longer raise exceptions which won't work in production.
Here's my worker code:
import logging
import logging.config
config = {
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout',
'level': 'DEBUG'
}
},
'root': {
'level': 'DEBUG',
'handlers': ['console']
}
}
logging.config.dictConfig(config)
log = logging.getLogger('test')
def raises():
'''This is the worker function'''
log.info('running raises')
raise RuntimeError
When the worker receives a job, it simply halts execution after the log statement, with no exception being raised:
12:28:09 log-test: log_test.raises() (d59ad742-4dcd-4d4f-84e2-6f747c21d603)
running raises
EDIT: Another interesting piece of the puzzle is that sys.excepthook
is not called in the worker context.