Files
2020-04-08 10:39:44 -07:00

20 lines
408 B
Python

import gevent
from functools import wraps
_NOT_ERROR = gevent.hub.Hub.NOT_ERROR
def silence_errors(f):
"""
Test decorator for gevent that silences all errors when
a greenlet raises an exception.
"""
@wraps(f)
def wrapper(*args, **kwargs):
gevent.hub.Hub.NOT_ERROR = (Exception,)
f(*args, **kwargs)
gevent.hub.Hub.NOT_ERROR = _NOT_ERROR
return wrapper