Skip to content

Commit

Permalink
doc: Use finally for teardown in doco examples
Browse files Browse the repository at this point in the history
This should encourage better handling of non-^C exit conditions in API
based use.
  • Loading branch information
maybe-sybr authored and BoboTiG committed Oct 22, 2020
1 parent b803b3e commit 7ddd5d4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -33,9 +33,9 @@ as command-line arguments and logs events generated:
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
finally:
observer.stop()
observer.join()
observer.join()
Shell Utilities
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/logger.py
Expand Up @@ -14,6 +14,6 @@
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
finally:
observer.stop()
observer.join()
observer.join()
4 changes: 2 additions & 2 deletions docs/source/examples/patterns.py
Expand Up @@ -25,6 +25,6 @@ def on_any_event(self, event):
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
finally:
observer.stop()
observer.join()
observer.join()
4 changes: 2 additions & 2 deletions docs/source/examples/simple.py
Expand Up @@ -37,6 +37,6 @@ def on_modified(self, event):
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
finally:
observer.stop()
observer.join()
observer.join()
4 changes: 2 additions & 2 deletions docs/source/quickstart.rst
Expand Up @@ -48,8 +48,8 @@ file system changes and simply log them to the console::
try:
while observer.isAlive():
observer.join(1)
except KeyboardInterrupt:
finally:
observer.stop()
observer.join()
observer.join()

To stop the program, press Control-C.

0 comments on commit 7ddd5d4

Please sign in to comment.