def _unpatch_logging_handlers_lock():
# we dont want to use logger locks since those are used by both real thread and gevent greenlets
# switching from one to the other will cause gevent hub to throw an exception
import logging
RLock = gevent.monkey.saved['threading']['_CRLock']
for handler in logging._handlers.values():
if handler.lock:
handler.lock = RLock()
def create_unpatched_lock_for_handler(handler):
handler.lock = RLock()
# patch future handlers
logging.Handler.createLock = create_unpatched_lock_for_handler
评论列表
文章目录