-
Notifications
You must be signed in to change notification settings - Fork 2
agent: run threads safely #61
New issue
Have a question about th 8000 is 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
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.
what about a simple test to reproduce the bug we had?
talker_agent/talker.py
Outdated
|
||
|
||
class SafeThread(threading.Thread): | ||
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, *, daemon=None): |
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.
let's make the name
argument non optional.
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 I think all arguments should be keyword arguments to avoid confusion
talker_agent/talker.py
Outdated
def run(self): | global first_exception_info | |
try: | ||
if self._target: |
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.
and if not?
talker_agent/talker.py
Outdated
self._target(*self._args, **self._kwargs) | ||
except: | ||
exc_info = sys.exc_info() | ||
logger.debug("exception in '%s'", self.name, exc_info=exc_info) |
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.
better log this to info
so it will get to the machine's syslog
talker_agent/talker.py
Outdated
exc_info = sys.exc_info() | ||
logger.debug("exception in '%s'", self.name, exc_info=exc_info) | ||
if not first_exception_info: | ||
first_exception_info = sys.exc_info() |
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.
shouldn't this be wrapped with a lock?
8909732
to
952db29
Compare
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.
lets add a test and update changelog
CHANGELOG.md
Outdated
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | |||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |||
|
|||
## [Unreleased] | |||
### Changed | |||
- make all agent threads thread-safe |
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.
not really a user facing change. maybe a bug fix
9bde5b6
to
b26b5f1
Compare
No description provided.