Fix killing greenlets gevent exception

This commit is contained in:
shortcutme 2020-06-30 17:04:47 +02:00
parent ddbd5c7b19
commit 6bd49e8aff
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
3 changed files with 15 additions and 5 deletions

View file

@ -6,13 +6,19 @@ from Config import config
# Non fatal exception
class Notify(Exception):
def __init__(self, message):
self.message = message
def __init__(self, message=None):
if message:
self.message = message
def __str__(self):
return self.message
# Gevent greenlet.kill accept Exception type
def createNotifyType(message):
return type("Notify", (Notify, ), {"message": message})
def formatExceptionMessage(err):
err_type = err.__class__.__name__
if err.args:
@ -101,6 +107,8 @@ import time
num_block = 0
def testBlock():
global num_block
logging.debug("Gevent block checker started")
@ -111,6 +119,8 @@ def testBlock():
logging.debug("Gevent block detected: %.3fs" % (time.time() - last_time - 1))
num_block += 1
last_time = time.time()
gevent.spawn(testBlock)