mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Fix reset load_code_from_local in 2nd session. (#13985)
Co-authored-by: Qing Wang <jovany.wq@antgroup.com>
This commit is contained in:
parent
af8c0c1add
commit
b579186791
2 changed files with 25 additions and 0 deletions
|
@ -75,6 +75,20 @@ class TestRedisPassword:
|
|||
ray.get(object_ref)
|
||||
|
||||
|
||||
def test_shutdown_and_reset_global_worker(shutdown_only):
|
||||
ray.init(job_config=ray.job_config.JobConfig(code_search_path=["a"]))
|
||||
ray.shutdown()
|
||||
ray.init()
|
||||
|
||||
@ray.remote
|
||||
class A:
|
||||
def f(self):
|
||||
return 100
|
||||
|
||||
a = A.remote()
|
||||
ray.get(a.f.remote())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
import sys
|
||||
|
|
|
@ -772,6 +772,17 @@ def init(
|
|||
job_config=job_config)
|
||||
if job_config and job_config.code_search_path:
|
||||
global_worker.set_load_code_from_local(True)
|
||||
else:
|
||||
# Because `ray.shutdown()` doesn't reset this flag, for multiple
|
||||
# sessions in one process, the 2nd `ray.init()` will reuse the
|
||||
# flag of last session. For example:
|
||||
# ray.init(load_code_from_local=True)
|
||||
# ray.shutdown()
|
||||
# ray.init()
|
||||
# # Here the flag `load_code_from_local` is still True if we
|
||||
# # doesn't have this `else` branch.
|
||||
# ray.shutdown()
|
||||
global_worker.set_load_code_from_local(False)
|
||||
|
||||
for hook in _post_init_hooks:
|
||||
hook()
|
||||
|
|
Loading…
Add table
Reference in a new issue