-
Notifications
You must be signed in to change notification settings - Fork 99
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
Added a global lock for the safe_save function to make sure XML files… #186
Conversation
Hi Mark, I'm keen to get this in asap :) Do you know from reading this code do we ever have a point where the 'data' file doesn't exist temporarily? I just wonder if a user hitting Ctrl+C at the wrong time would be exposed to this again a bit more? |
Firstly the lock should be acquired and released using a context manager otherwise we will end up with dangling locks. Secondly, do we really want a global lock or just one per object/file? If there any problem with writing job1 and job2 at the same time? |
Stupid - now changed to using context manager! For the moment, I would prefer (and it looks like @rob-c agrees) to use a global lock so we can be absolutely sure this has gone away. This may hit performance a little but hopefully not a lot. After we've got more testing for these things, then I would suggest revisiting it. E.g. I suspect this lock won't b needed anyway given the locking that's being added for the monitoring but better to be safe than sorry at the moment :) Btw, I've added a safe_save unit test that recreates the bug to this PR as well. |
@@ -0,0 +1,31 @@ | |||
from ..GangaUnitTest import GangaUnitTest | |||
|
|||
class Issue185(GangaUnitTest): |
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.
For consistency with the others, let's call these GitHub185
.
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, since this doesn't use any of the Ganga runtime machinery I'd rather this was done as a standard UnitTest, not in the GPI
directory. In a while I'm going to have to rearrange these anyway but if this is already in the right pace then it will be easier.
In fact, I would just call this test_safe_save
and keep it as a generic unit test for the function rather than tying it to a specific issue.
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.
Where is the place to put this to make sure it's run then? It certainly doesn't need the GPI but from what I could glean from Jenkins, we're only running tests in new_tests/GPI
...
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.
By tests I mean the PR tests!
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.
You're right, it was just running over new_tests/GPI
but I've just changed it so that it runs over all of new_tests
so this will include all unit tests too. I'm not sure why I hadn't set it up like that before.
Forgot to say: the code to move the |
OK, Erm We should probably change the load mechanism to check for a |
I agree - it's a minor point but should be made of a note of :) |
I think that addresses everything - if so, let me know and I'll merge, or @milliams as release manager can do the honours :) |
There's a brief problem with the Jenkins tests which I'm working to resolve before we can test and merge this. I'll let you know. |
I'm happy to merge but we should bear in mind the future potential for a per-object lock (or perhaps it becomes unnecessary with the 👍 |
@milliams There is a per-object lock in the Registry which only works per-object per registry and doesn't protect against the bug this is fixing. |
Added a global lock for the safe_save function to make sure XML files don't disappear. Fixes #185
… don't disappear.
Fixes #185.