-
Notifications
You must be signed in to change notification settings - Fork 13
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
Race Conditions when using OpCodes and session.status #607
Comments
Cool that code comment says "you can't trust session.d for purpose X" and then about 8 lines later we use session.d for purpose X ... I think a quick fix is to add a second Deferred to session ( |
I was thinking something along those lines, but another issue I've seen is that session.set_status('running')
print(session.status) this will not update immediately, since it is being scheduled to run in the main thread. Like in the testing example above, when the response is returned from wait (without the sleep) it looks like this:
Meaning that session.success was updated in the So I'm not entirely sure that when running a callback from after |
Ah, yes. I see what you mean. That will require a bit more thought to get the final Deferred to fire only once the state is fully up to date. |
Ok, actually, I really don't understand how this could happen. And I also can't reproduce it. That session dict you show should really be impossible. I think But that puzzle aside ^^^, I do acknowledge these other more clear cut problems:
Let's hack on it on next week (if we don't figure it out before then). |
Ok I was really curious so started poking around a bit more and think I know why this is happening.... This is due to the new structure of the OCS agents. For reference, here is the task that's causing this issue: socs/socs/agents/hwp_pmx/agent.py Lines 133 to 141 in 710d8a3
I think what's happening, is that the Really stretching my intuition for python and twisted here To fix maybe the best way is to wrap |
Ahhh, that makes some sense then. Yes, wrap all three uses of action.deferred in |
Confirmed, using callFromThread on the callback makes it so the session is self-consistent in the test above. I think the |
I think ocs:371 means we can close this? |
Yep! |
I'm encountering the following issue when trying to fix tests for the HWP PMX agent:
The following test is failing the assertion that
assert resp.session['op_code'] == OpCode.SUCCEEDED.value
with the following error message:
Based on logs, the
session.status
inresp
is still in thestarting
state, instead of done, and the OpCode isSTARTING
.This following test passes:
I think the change that instigated this issue is switching tasks from being blocking to non-blocking.
I think this is due to a race-condition in when
wait
resolves compared to when the session-status is updated. This points to a slightly deeper OCS issue that I think @mhasself has experience with (based on comments in the src)There may be a way to fix this in OCS through use of callback-chains or something, but for now I think we need to be really careful about using OpCode or session.status in tests or for control flow.
The text was updated successfully, but these errors were encountered: