Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
The deadlock caused by inconsistent thread ident (RLock of logging handlers)
import logging
import itertools
import gevent.monkey
class SlowHandler(logging.Handler):
def emit(self, record):
gevent.sleep(1)
logging.basicConfig()
logger = logging.getLogger(__name__)
# gevent.monkey.patch_all()
logger.addHandler(SlowHandler())
gevent.monkey.patch_all()
def dump_sth(name):
for idx in itertools.count():
logger.warning('=> %s %s' % (name, idx))
gevent.sleep(0)
gevent.spawn(dump_sth, 'foo')
gevent.spawn(dump_sth, 'bar')
gevent.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment