Skip to content

Commit

Permalink
Set app eventloop as background as default
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Oct 3, 2023
1 parent 5b83d0e commit 75aaffe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ably/executer/eventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def __init__(self, loop, thread=None):
@staticmethod
def get_global() -> 'AppEventLoop':
if AppEventLoop._global is None or not AppEventLoop._global.__is_active:
AppEventLoop._global = AppEventLoop.create(True)
AppEventLoop._global = AppEventLoop.create()
return AppEventLoop._global

@staticmethod
def create(background=False) -> 'AppEventLoop':
def create() -> 'AppEventLoop':
loop = asyncio.new_event_loop()
thread = threading.Thread(target=loop.run_forever, daemon=background)
thread = threading.Thread(target=loop.run_forever, daemon=True)
thread.start()
return AppEventLoop(loop, thread)

Expand Down
2 changes: 1 addition & 1 deletion ably/rest/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, key: Optional[str] = None, token: Optional[str] = None,
self.__sync_enabled = options.sync_enabled
if self.__sync_enabled:
if options.loop is None:
self.__app_loop = AppEventLoop.create(True)
self.__app_loop = AppEventLoop.create()
else:
self.__app_loop = AppEventLoop(loop=options.loop)

Expand Down

0 comments on commit 75aaffe

Please sign in to comment.