Added the possibility to initialize the event loop without starting it

This commit is contained in:
nocturn9x 2021-07-14 12:18:04 +02:00
parent f44b3806fe
commit 2003f096f6
1 changed files with 5 additions and 4 deletions

View File

@ -468,7 +468,7 @@ class AsyncScheduler:
self.run_ready.append(key.data) # Resource ready? Schedule its task
self.debugger.after_io(self.clock() - before_time)
def start(self, func: types.FunctionType, *args):
def start(self, func: types.FunctionType, *args, loop: bool = True):
"""
Starts the event loop from a sync context
"""
@ -477,9 +477,10 @@ class AsyncScheduler:
self.tasks.append(entry)
self.run_ready.append(entry)
self.debugger.on_start()
self.run()
self.has_ran = True
self.debugger.on_exit()
if loop:
self.run()
self.has_ran = True
self.debugger.on_exit()
def cancel_pool(self, pool: TaskManager) -> bool:
"""