Supported engines¶
AsyncIOEngine¶
Runs code as asyncio coroutines:
from concurrently import concurrently, AsyncIOEngine
...
@concurrently(2, engine=AsyncIOEngine, loop=loop) # loop is option
async def fetch_urls():
...
await fetch_urls()
-
class
concurrently.
AsyncIOEngine
(loop: asyncio.base_events.BaseEventLoop = None)¶ Parameters: loop – specific asyncio loop or use default if None
AsyncIOThreadEngine¶
Runs code in threads with asyncio:
from concurrently import concurrently, AsyncIOThreadEngine
...
@concurrently(2, engine=AsyncIOThreadEngine, loop=loop)
def fetch_urls(): # not async def
...
await fetch_urls()
-
class
concurrently.
AsyncIOThreadEngine
(loop: asyncio.base_events.BaseEventLoop = None)¶ Parameters: loop – specific asyncio loop or use default if None
ThreadEngine¶
Runs code in system threads:
from concurrently import concurrently, ThreadEngine
...
@concurrently(2, engine=ThreadEngine)
def fetch_urls(): # not async def
...
fetch_urls() # not await
-
class
concurrently.
ThreadEngine
¶