[Python-Dev] A more flexible task creation (original) (raw)

Tin Tvrtković tinchester at gmail.com
Thu Jun 14 18:31:12 EDT 2018


On Thu, Jun 14, 2018 at 10:03 PM Steve Dower <steve.dower at python.org> wrote:

I often use semaphores for this when I need it, and it looks like asyncio.Semaphore() is sufficient for this:

import asyncio tasklimiter = asyncio.Semaphore(4) async def mytask(): await tasklimiter.acquire() try: await dodbrequest() finally: tasklimiter.release()

Yeah, a semaphore logically fits exactly but



More information about the Python-Dev mailing list