Skip to content

Commit

Permalink
[watchmedo] Exit gracefully on KeyboardInterrupt exception (Ctrl+C) (#…
Browse files Browse the repository at this point in the history
…945)

* [watchmedo] Exit gracefully on KeyboardInterrupt Exception (Ctrl+C keystroke)

Uses system exit code 130.

* Update changelog.rst

---------

Co-authored-by: J. Cernek <spam.github@cernek.cz>
Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
  • Loading branch information
3 people authored Feb 20, 2023
1 parent 3140f52 commit d2837e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog

- [inotify] Add support for ``IN_OPEN`` events: a ``FileOpenedEvent`` event will be fired. (`#941 <https://github.com/gorakhargosh/watchdog/pull/941>`__)
- [watchmedo] Add optional event debouncing for ``auto-restart``, only restarting once if many events happen in quick succession (`#940 <https://github.com/gorakhargosh/watchdog/pull/940>`__)
- [watchmedo] Exit gracefully on ``KeyboardInterrupt`` exception (Ctrl+C) (`#945 <https://github.com/gorakhargosh/watchdog/pull/945>`__)
- Thanks to our beloved contributors: @BoboTiG, @dstaple, @taleinat

2.2.1
Expand Down
6 changes: 5 additions & 1 deletion src/watchdog/watchmedo.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,11 @@ def main():
return 1
logging.getLogger('watchdog').setLevel(log_level)

args.func(args)
try:
args.func(args)
except KeyboardInterrupt:
return 130

return 0


Expand Down

0 comments on commit d2837e9

Please sign in to comment.