-
Notifications
You must be signed in to change notification settings - Fork 373
Make __del__ call shutdown and close in DataCollectors and Envs #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I noticed that too, thanks for identifying the issue! I see basically 2 options: either we make sure that this phenomenon never happens or we revert and ask users to close the collector / env when it's not used, otherwise an error is thrown. |
…ut shutdown before
Introduce failure of processes when idle for a while
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's think about what would be the behaviour of the test without the new feature.
pin_memory=False, | ||
) | ||
for i, d in enumerate(ccollector): | ||
if i == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can just break when i == 2 or something
b2c = d | ||
else: | ||
break | ||
with pytest.raises(AssertionError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is tested elsewhere
@@ -107,7 +107,7 @@ def env_fn(seed): | |||
break | |||
with pytest.raises(AssertionError): | |||
assert_allclose_td(b1, b2) | |||
collector.shutdown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep these, as we test it somewhere else?
Like this if for some reason the new feature breaks only that test will fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
@@ -129,7 +129,6 @@ def test_env_seed(env_name, frame_skip, seed=0): | |||
assert_allclose_td(td0a, td0c.select(*td0a.keys())) | |||
with pytest.raises(AssertionError): | |||
assert_allclose_td(td1a, td1c) | |||
env.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep these though, for the same reason as above.
But if we can test that things work properly in a separate function that's even better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
assert_allclose_td(b1c, b2c) | ||
|
||
if should_shutdown: | ||
ccollector.shutdown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the function hangs forever, the test will not fail (it will not close)
Do you think that without the new feature we'd get a meaningful error message with this?
@@ -87,7 +87,7 @@ def _check_for_faulty_process(processes): | |||
break | |||
if terminate: | |||
raise RuntimeError( | |||
"At least on process failed. Check for more infos in the log." | |||
"At least one process failed. Check for more infos in the log." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
Rearrange the code and remove unneeded error handling so shutdown and close functions will be called from the del function.
From the unit tests it seems that:
del collector
in the end to the unit test, the test hangs in the end.