mirror of
https://github.com/wassname/ray.git
synced 2026-07-05 06:14:06 +08:00
[Parallel Iterator] Foreach concur (#8140)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user