diff --git a/ably/decorator/sync.py b/ably/decorator/sync.py index 2db3e054..b79c55d6 100644 --- a/ably/decorator/sync.py +++ b/ably/decorator/sync.py @@ -34,12 +34,9 @@ def wrapper(*args, **kwargs): except: pass ably_eventloop = get_custom_event_loop() - res = fn(*args, **kwargs) - if asyncio.iscoroutine(res): - future = asyncio.run_coroutine_threadsafe(res, ably_eventloop) - if caller_eventloop is not None and caller_eventloop.is_running(): - return asyncio.wrap_future(future) - return future.result() - return res + future = asyncio.run_coroutine_threadsafe(fn(*args, **kwargs), ably_eventloop) + if caller_eventloop is not None and caller_eventloop.is_running(): + return asyncio.wrap_future(future) + return future.result() return wrapper