Skip to content

Conversation

eloise-nebula
Copy link
Contributor

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 on self.__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 new is_destroyed function provides a threadsafe way of checking the lifecycle flag from within _dispatch_action.

Copy link
Member

@robnagler robnagler left a 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.

Copy link
Member

@robnagler robnagler left a 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:
Copy link
Member

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

@eloise-nebula eloise-nebula marked this pull request as ready for review October 6, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants