mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 01:57:09 +08:00
Separate thread locks for worker and function manager. (#4499)
* Separate lock for function manager and worker * Lint * Add test case * Remove print in remote function. * Remove test and add ray.exit_actor * Update python/ray/worker.py Co-Authored-By: guoyuhong <guoyuhong1985@outlook.com> * Move exit_actor from worker.py to actor.py * Update actor.py * Update actor.py
This commit is contained in:
+13
-15
@@ -56,11 +56,10 @@ class ImportThread(object):
|
||||
|
||||
try:
|
||||
# Get the exports that occurred before the call to subscribe.
|
||||
with self.worker.lock:
|
||||
export_keys = self.redis_client.lrange("Exports", 0, -1)
|
||||
for key in export_keys:
|
||||
num_imported += 1
|
||||
self._process_key(key)
|
||||
export_keys = self.redis_client.lrange("Exports", 0, -1)
|
||||
for key in export_keys:
|
||||
num_imported += 1
|
||||
self._process_key(key)
|
||||
|
||||
while True:
|
||||
# Exit if we received a signal that we should stop.
|
||||
@@ -72,16 +71,15 @@ class ImportThread(object):
|
||||
self.threads_stopped.wait(timeout=0.01)
|
||||
continue
|
||||
|
||||
with self.worker.lock:
|
||||
if msg["type"] == "subscribe":
|
||||
continue
|
||||
assert msg["data"] == b"rpush"
|
||||
num_imports = self.redis_client.llen("Exports")
|
||||
assert num_imports >= num_imported
|
||||
for i in range(num_imported, num_imports):
|
||||
num_imported += 1
|
||||
key = self.redis_client.lindex("Exports", i)
|
||||
self._process_key(key)
|
||||
if msg["type"] == "subscribe":
|
||||
continue
|
||||
assert msg["data"] == b"rpush"
|
||||
num_imports = self.redis_client.llen("Exports")
|
||||
assert num_imports >= num_imported
|
||||
for i in range(num_imported, num_imports):
|
||||
num_imported += 1
|
||||
key = self.redis_client.lindex("Exports", i)
|
||||
self._process_key(key)
|
||||
finally:
|
||||
# Close the pubsub client to avoid leaking file descriptors.
|
||||
import_pubsub_client.close()
|
||||
|
||||
Reference in New Issue
Block a user