Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save westhood/5269090 to your computer and use it in GitHub Desktop.

Select an option

Save westhood/5269090 to your computer and use it in GitHub Desktop.
import gevent.monkey
import logging
logger = logging.getLogger(__name__)
logger.info("Gevent monkey patch is applied")
gevent.monkey.patch_all()
# RLock of sentry log handler may be created before applying gevent monkey
# patch, which will lead to a deadlock. Replace it with a gevent RLock
for handler in logger.root.handlers:
if handler.get_name() == "sentry":
logger.info("Replace the RLock of sentry log handler to a gevent RLock")
handler.createLock()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment