Skip to content
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
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions circus/plugins/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class WatchDog(CircusPlugin):
used when killing the processes
"""
name = 'watchdog'
plugin_name = 'plugin:' + name

def __init__(self, endpoint, pubsub_endpoint, check_delay, ssh_server,
**config):
Expand Down Expand Up @@ -136,7 +137,9 @@ def _discover_monitored_pids(self):
self.pid_status = dict()
all_watchers = self.call("list")
for watcher_name in all_watchers['watchers']:
if self._match_watcher_name(watcher_name):
# do not discover watchdog
if self._match_watcher_name(watcher_name) and \
watcher_name != self.plugin_name:
processes = self.call("list", name=watcher_name)
if 'pids' in processes:
for pid in processes['pids']:
Expand Down Expand Up @@ -182,7 +185,7 @@ def _decode_received_udp_message(self, data):
:return: decoded message
:rtype: dict or None
"""
result = re.match(self.msg_regex, data)
result = re.match(self.msg_regex, data.decode())
Copy link
Contributor

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 ;) .

if result is not None:
return result.groupdict()

Expand Down Expand Up @@ -217,6 +220,9 @@ 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.
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 !",
Expand All @@ -233,4 +239,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]
1 change: 1 addition & 0 deletions circus/tests/test_plugin_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ def test_watchdog_discovery_not_found(self):
self.assertEqual(len(pid_status), 0, pid_status)
yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)