Skip to content

Instantly share code, notes, and snippets.

@cwells
Created May 2, 2019 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwells/11a12b5e7c70b531d31d86dae159ad47 to your computer and use it in GitHub Desktop.
Save cwells/11a12b5e7c70b531d31d86dae159ad47 to your computer and use it in GitHub Desktop.
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