Skip to content

Commit

Permalink
More graceful shutdowns of ray if tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Mar 1, 2022
1 parent 4e9c44c commit d21b8a2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions test/single/test_ray.py
Expand Up @@ -22,17 +22,21 @@
@pytest.fixture
def ray_start_2_cpus():
address_info = ray.init(num_cpus=2)
yield address_info
# The code after the yield will run as teardown code.
ray.shutdown()
try:
yield address_info
finally:
# The code after the yield will run as teardown code.
ray.shutdown()


@pytest.fixture
def ray_start_4_cpus():
address_info = ray.init(num_cpus=4, _redis_max_memory=1024 * 1024 * 1024)
yield address_info
# The code after the yield will run as teardown code.
ray.shutdown()
try:
yield address_info
finally:
# The code after the yield will run as teardown code.
ray.shutdown()


@pytest.fixture
Expand All @@ -53,12 +57,12 @@ def ray_start_4_cpus_4_gpus():
try:
yield address_info
# The code after the yield will run as teardown code.
ray.shutdown()
finally:
if orig_devices:
os.environ["CUDA_VISIBLE_DEVICES"] = orig_devices
else:
del os.environ["CUDA_VISIBLE_DEVICES"]
ray.shutdown()


@pytest.fixture
Expand Down

0 comments on commit d21b8a2

Please sign in to comment.