Recent posts
Tag: #loop · 1 posts
Posted Jul 11
https://docs.python.org/3/library/asyncio-eventloop.html #Calls Most #asyncio functions don’t accept keywords. If you want to pass #keywords to your callback, use #functools.partial(). For example, #loop.#call_soon(functools.partial(print, "Hello", flush=True)) will call print("Hello", flush=True). #Note functools.partial() is better than lambda functions, because asyncio can inspect functools.partial() object to display parameters in debug mode, whereas lambda functions have a poor representation. BaseEventLoop.call_soon(callback, *args) Arrange for a callback to be called as soon as possible. The callback is called after call_soon() returns, when control returns to the event loop. This operates as a FIFO queue, callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. An instance of asyncio.Handle is returned, which can be used to cancel the callback. Use functools.partial to pass keywords to the callback. BaseEventLoop.call_soon_threadsafe(callback, *args) Like call_soon(), but thread safe. See the concurrency and multithreading section of the documentation.