Jul-12-2024, 05:18 AM
Hi,
Is there a way to run a function in a fire and forget manner in python using asyncio from a synchronous function
The code below doesn't work for me. the loop thsat I get from asyncio.get_event_loop() is not running.
Thanks for any pointer.
Terry
Is there a way to run a function in a fire and forget manner in python using asyncio from a synchronous function
The code below doesn't work for me. the loop thsat I get from asyncio.get_event_loop() is not running.
Thanks for any pointer.
Terry
def fire_and_forget(task, *args, **kwargs): loop = asyncio.get_event_loop() if callable(task): return loop.run_in_executor(None, task, *args, **kwargs) else: raise TypeError('Task must be a callable') def foo(): #asynchronous stuff here fire_and_forget(foo)