Skip to content Skip to sidebar Skip to footer

Running An Asynchronous Function 'in The Background'

I have several asynchronous functions. If I call _main(), I can't use the second _check() function, because _main() runs continuously in a while loop. Can I run _main() 'in the bac

Solution 1:

Can I run _main() 'in the background' to make the rest of the functions available?

Yes, you can replace await self._main() with asyncio.create_task(self._main()). That will spawn _main as a task that effectively runs in the background.


Post a Comment for "Running An Asynchronous Function 'in The Background'"