Skip to content

Commit

Permalink
Fixed eventloop closing deorator for rest sync
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Oct 3, 2023
1 parent 29e98fc commit 5cf52ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions ably/executer/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ def close_app_eventloop(fn):

@functools.wraps(fn)
def wrapper(self, *args, **kwargs):

app_loop: events = self.app_loop

# todo - this decorator will change if eventloop is also active for async operations
if not self.sync_enabled:
app_loop.close()
return fn(self, *args, **kwargs)

# Block the caller till result is returned
app_loop: events = self.app_loop
future = asyncio.run_coroutine_threadsafe(fn(self, *args, **kwargs), app_loop.loop)
result = future.result()
app_loop.close()
Expand Down
2 changes: 1 addition & 1 deletion ably/executer/eventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AppEventLoop:
__thread: threading
__is_active: bool

def __init__(self, loop=None, thread=None):
def __init__(self, loop, thread=None):
if not loop.is_running:
raise Exception("Provided eventloop must be in running state")
self.__loop = loop
Expand Down

0 comments on commit 5cf52ce

Please sign in to comment.