-
Notifications
You must be signed in to change notification settings - Fork 257
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
python3 fixes #963
Open
kyudin
wants to merge
6
commits into
circus-tent:master
Choose a base branch
from
kyudin:watchdog_python3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
python3 fixes #963
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee9f84b
python3 fixes
kyudin ecbcdd2
fix comments and len of string
kyudin ea38643
add tests and return check for watchdog discovering
kyudin ab0cce3
comment test for now and remove watchdog discover check
kyudin 556724b
do not discover watchdog, remove/fix comments
kyudin 4493a8a
flake8 fixes
kyudin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,7 @@ def _discover_monitored_pids(self): | |
self.pid_status = dict() | ||
all_watchers = self.call("list") | ||
for watcher_name in all_watchers['watchers']: | ||
# TODO: Do not discover watchdog | ||
if self._match_watcher_name(watcher_name): | ||
processes = self.call("list", name=watcher_name) | ||
if 'pids' in processes: | ||
|
@@ -182,7 +183,12 @@ def _decode_received_udp_message(self, data): | |
:return: decoded message | ||
:rtype: dict or None | ||
""" | ||
result = re.match(self.msg_regex, data) | ||
"""regex is created with string, | ||
but bytes are received from the socket, | ||
that cause exception. | ||
Probably this can be done better, | ||
that just decode data""" | ||
result = re.match(self.msg_regex, data.decode()) | ||
if result is not None: | ||
return result.groupdict() | ||
|
||
|
@@ -217,6 +223,10 @@ def look_after(self): | |
|
||
max_timeout = self.loop_rate * self.max_count | ||
too_old_time = time.time() - max_timeout | ||
"""Instead of del in loop, that will cause exception in Python3, | ||
add to list and del from pid_status after loop. | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another solution would be to make a copy of the dict before the Could you make your comment as a real comment ( |
||
pids_to_del = list() | ||
for pid, detail in self.pid_status.items(): | ||
if detail['last_activity'] < too_old_time: | ||
logger.info("watcher:%s, pid:%s is not responding. Kill it !", | ||
|
@@ -233,4 +243,6 @@ def look_after(self): | |
|
||
# Trusting watcher to eventually stop the process after | ||
# graceful timeout | ||
del self.pid_status[pid] | ||
pids_to_del.append(pid) | ||
for pid in pids_to_del: | ||
del self.pid_status[pid] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It makes perfect sense, I think you can even remove your comment (the method is already named
decode_received_udp_message
;) .