-
Notifications
You must be signed in to change notification settings - Fork 8
Issue 613: Locking _dispatch_action #614
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
base: master
Are you sure you want to change the base?
Conversation
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 looks great. Only a few comments.
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.
Much better, thanks.
self._destroy() | ||
except Exception as e: | ||
pkdlog("error={} {} stack={}", e, self, pkdexc(simplify=True)) | ||
with self.__lock: |
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 self.__destroyed:
return
self.__destroyed = True
A rough sketch of my solution to #613. Moves
_dispatch_action
and_destroy
out of locks, but ensures that these two will never run simultaneously by letting the thread handle sequencing. Thread still exits onself.__destroyed
such that no additional work can be done. If_dispatch_action
is doing significant work it could take a while to exit, but that was already a problem. Plus, the newis_destroyed
function provides a threadsafe way of checking the lifecycle flag from within_dispatch_action
.