-
Notifications
You must be signed in to change notification settings - Fork 704
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
Zillion: Finalize item locations in either generate_output or fill_slot_data #4121
base: main
Are you sure you want to change the base?
Zillion: Finalize item locations in either generate_output or fill_slot_data #4121
Conversation
…tion `finalize_item_locations()` does not mutate `self` or any attribute of `self`, so fill_slot_data does not need to wait for `finalize_item_locations()` to be run. Previously, before 113c54f, synchronization was necessary because `finalize_item_locations()` would set location data into `self.zz_system.patcher`, which `fill_slot_data` would then read from. This also means that Zillion can be re-enabled for the test.general.test_implemented.test_slot_data test.
This might be ok, I'll have to look at it more closely. But this is wrong:
I'll look at it more when I get the time. |
Ah yes, you are correct. I'll have another look tomorrow, but initially it looks fine. |
This change doesn't look safe to me. There have been discussions in discord about a generation stage before multithreading but after all items are in their final locations. |
The problem with my test was that I only called I could change Edit: I guess I can synchronize both threads and have whichever of |
This reverts commit 73f30de.
…chronization" This reverts commit e18906b.
…ot_data `generate_output` and `fill_slot_data` are run in separate threads so there is no guarantee that one runs before the other. Before this patch, the threads were synchronized by making `fill_slot_data` wait for `generate_output`. The problem with doing this is that the test.general.test_implemented.test_slot_data test does not run `generate_output`, so Zillion had to be disabled from the test. This patch changes the synchronization of the threads such that it does not matter which function is run first. Whichever function is run first will run `finalize_item_locations()` and the other function will wait until `finalize_item_locations()` is complete and has been cached in a new instance attribute. Zillion has now been re-enabled for the test.general.test_implemented.test_slot_data test.
I have updated the PR to do this instead. |
This looks like it will probably be good. I'll play through a test game some time soon. |
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.
tested a 2-player game
Co-authored-by: Doug Hoskisson <[email protected]>
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.
also tested after latest change
This has conflicts btw |
# Conflicts: # worlds/zillion/__init__.py
What is this fixing or adding?
generate_output
andfill_slot_data
are run in separate threads so there is no guarantee that one runs before the other.Before this patch, the threads were synchronized by making
fill_slot_data
wait forgenerate_output
. The problem with doing this is that the test.general.test_implemented.test_slot_data test does not rungenerate_output
, so Zillion had to be disabled from the test.This patch changes the synchronization of the threads such that it does not matter which function is run first. Whichever function is run first will run
finalize_item_locations()
and the other function will wait untilfinalize_item_locations()
is complete and has been cached in a new instance attribute.Zillion has now been re-enabled for the test.general.test_implemented.test_slot_data test.
How was this tested?
I dumped slot data to a .json file and used thread synchronization to force
fill_slot_data
to run beforegenerate_output
. Then did the same but forcedgenerate_output
to run beforefill_slot_data
. The slot data json files written in both cases were identical.I also ran the test_slot_data test with
fill_slot_data
modified to raise an exception to confirm that it was now being tested.