semaphore

Python: Is there a way to join threads while using semaphores

Python: Is there a way to join threads while using semaphores Question: Background: I have an inventory application that scrapes data from our various IT resources (VMware, storage, backups, etc…) We have a vCenter that has over 2000 VMs registered to it. I have code to go in and pull details for each VM in …

Total answers: 1

asyncio.Semaphore RuntimeError: Task got Future attached to a different loop

asyncio.Semaphore RuntimeError: Task got Future attached to a different loop Question: When I run this code in Python 3.7: import asyncio sem = asyncio.Semaphore(2) async def work(): async with sem: print(‘working’) await asyncio.sleep(1) async def main(): await asyncio.gather(work(), work(), work()) asyncio.run(main()) It fails with RuntimeError: $ python3 demo.py working working Traceback (most recent call last): …

Total answers: 2

Named semaphores in Python?

Named semaphores in Python? Question: I have a script in python which uses a resource which can not be used by more than a certain amount of concurrent scripts running. Classically, this would be solved by a named semaphores but I can not find those in the documentation of the multiprocessing module or threading . …

Total answers: 2