-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed as not planned
Labels
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))
arhadthedev, pcuenca, greyblue9, kumaraditya303, rabernat and 2 moregreyblue9, codycoggins, kortsi and basnijholt
Metadata
Metadata
Assignees
Labels
Projects
Status
Done