Commit 2870c3c
committed
Avoid race condition for subscribers
If several monitors (each is a subscriber) are attached to an everest
server, the server could crash with a RuntimeError when tearing down;
Traceback (most recent call last):
File "/data/projects/ert/src/ert/dark_storage/endpoints/experiment_server.py", line 341, in run
for sub in shared_data.subscribers.values():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: dictionary changed size during iteration
This is because there is an await in the loop execution body, which
allows the async loop to add a new subscriber while we are iterating.
By expanding the values() iterator to a fixed list before looping, we
avoid the possibility of a race condition (but we are leaving behind the
possible late added subscriber)
Repeated testing with multiple monitors with this patch has not
revealed any further issues.1 parent 6434fe3 commit 2870c3c
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
| 341 | + | |
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| |||
0 commit comments