Created
May 2, 2019 16:30
-
-
Save cwells/11a12b5e7c70b531d31d86dae159ad47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
def async_compat(func): | |
@functools.wraps(func) | |
def wrapper_decorator(*args, **kwargs): | |
version = sys.version_info[0] + sys.version_info[1] / 10.0 | |
if version >= 3.7: | |
kwargs['is_async'] = kwargs.get('async', False) | |
del kwargs['async'] | |
return func(*args, **kwargs) | |
return wrapper_decorator | |
@async_compat | |
def start_stream(stream, **kwargs): | |
"""Start the stream, prints the disconnection error | |
Args: | |
stream (obj): stream object to start | |
""" | |
try: | |
stream.filter(**kwargs) | |
except Exception: | |
stream.disconnect() | |
print("Fatal exception") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment