Closed as not planned
Description
Feature or enhancement
Support for running async functions in sync functions
Pitch
Currently running async functions inside sync functions is only available with
asyncio.run(func(x))
or loop.run_until_complete()
; however when there is a running loop, these calls cannot be used.
The only way is running the function in background, and using callback functions(which is very limiting)
event_loop = asyncio.get_event_loop()
task = event_loop.create_task(func(*args))
task.add_done_callback(callback_func)
See example PR
I think there should be function to handle all cases of running async funcs in sync funcs
- when there is no event_loop
- when there is already running event_loop
Suggested syntax:synchronize_async(func(*args))
Metadata
Metadata
Assignees
Projects
Status
Done