AsyncIOProcessingService
class¶
Bases: ProcessingService
A processing service that utilizes the AsyncIO
framework to handle the execution of calls.
Notes:
-
When the provided callback is a synchronous call, it will be executed in a blocking manner, regardless of whether an event loop is active. However, if the synchronous callback involves I/O or non-CPU-bound operations, it can be offloaded to a thread pool using
asyncio.to_thread()
from theAsyncIO
framework. -
When the provided callback is an asynchronous call and is submitted in a context where an event loop is already running, the callback is scheduled and processed on that existing loop. If the event loop exits before all calls are completed, any remaining scheduled calls will be canceled.
-
When the provided callback is an asynchronous call and is submitted in a context where no event loop is active, a new event loop is started and subsequently closed by the
asyncio.run()
method. Within this loop, the callback is executed, and the loop waits for all scheduled tasks to finish before closing.
Source code in pyventus/core/processing/asyncio/asyncio_processing_service.py
Functions¶
is_loop_running
staticmethod
¶
Determine whether there is currently an active AsyncIO
event loop.
RETURNS | DESCRIPTION |
---|---|
bool
|
|
Source code in pyventus/core/processing/asyncio/asyncio_processing_service.py
__init__
¶
Initialize an instance of AsyncIOProcessingService
.
RETURNS | DESCRIPTION |
---|---|
None
|
None. |
submit
¶
Source code in pyventus/core/processing/asyncio/asyncio_processing_service.py
wait_for_tasks
async
¶
Wait for all background tasks associated with the current service to complete.
This method ensures that any ongoing tasks are finished before proceeding.
RETURNS | DESCRIPTION |
---|---|
None
|
None. |