Skip to content

Commit

Permalink
Catch KeyboardInterrupt exceptions and stop processes gracefully when…
Browse files Browse the repository at this point in the history
… catched
  • Loading branch information
dnaeon committed Sep 3, 2014
1 parent 2b0b5b2 commit c0a0694
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/vpoller/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def start(self):

logging.info('Proxy Manager is ready and running')
while not self.time_to_die.is_set():
self.wait_for_mgmt_task()
try:
self.wait_for_mgmt_task()
except KeyboardInterrupt:
self.signal_stop()

self.stop()

Expand Down Expand Up @@ -279,7 +282,10 @@ def run(self):

logging.info('Proxy process is ready and running')
while not self.time_to_die.is_set():
self.distribute_tasks()
try:
self.distribute_tasks()
except KeyboardInterrupt:
self.signal_stop()

self.stop()

Expand Down
10 changes: 8 additions & 2 deletions src/vpoller/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def start(self):

logging.info('Worker Manager is ready and running')
while not self.time_to_die.is_set():
self.wait_for_mgmt_task()
try:
self.wait_for_mgmt_task()
except KeyboardInterrupt:
self.signal_stop()

self.stop()

Expand Down Expand Up @@ -307,7 +310,10 @@ def run(self):

logging.info('Worker process is ready and running')
while not self.time_to_die.is_set():
self.wait_for_tasks()
try:
self.wait_for_tasks()
except KeyboardInterrupt:
self.signal_stop()

self.stop()

Expand Down

0 comments on commit c0a0694

Please sign in to comment.