Skip to content

Commit

Permalink
Removed unnecessary coroutine check for decorater sync
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Sep 29, 2023
1 parent 0a71845 commit a8522d0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ably/decorator/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a8522d0

Please sign in to comment.