[Parallel Iterator] Foreach concur (#8140)

This commit is contained in:
Alex Wu
2020-05-06 08:00:01 -07:00
committed by GitHub
parent ec9357b486
commit 04813c2ef5
3 changed files with 137 additions and 19 deletions
+15
View File
@@ -223,6 +223,21 @@ class SignalActor:
await self.ready_event.wait()
@ray.remote(num_cpus=0)
class Semaphore:
def __init__(self, value=1):
self._sema = asyncio.Semaphore(value=value)
async def acquire(self):
self._sema.acquire()
async def release(self):
self._sema.release()
async def locked(self):
return self._sema.locked()
@ray.remote
def _put(obj):
return obj