Skip to content
Snippets Groups Projects
Commit 7e7969df authored by pi's avatar pi
Browse files

couroutines are now retured so you can cancel them

parent 9fb31ff8
No related branches found
No related tags found
No related merge requests found
......@@ -73,9 +73,9 @@ class AsyncLoop:
def call_in_main_thread(self, callback: Callable[[],None]):
self._loop.call_soon_threadsafe(callback)
def attach_coroutine(self, coroutine: asyncio.coroutine):
def attach_coroutine(self, coroutine: asyncio.coroutine) -> asyncio.Task:
""" attaches a coroutine to the event loop """
self._loop.create_task(coroutine)
return self._loop.create_task(coroutine)
def run(self):
self.start()
......@@ -143,7 +143,7 @@ class AsyncLoop:
if cleanup:
cleanup()
# Create and return a task for the ticker coroutine
self.attach_coroutine(my_ticker())
return self.attach_coroutine(my_ticker())
......
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment