Skip to content

Instantly share code, notes, and snippets.

@simryang
Created July 10, 2020 07:22
Show Gist options
  • Save simryang/5497cbfc9520100f2a0178475ebdf6a4 to your computer and use it in GitHub Desktop.
Save simryang/5497cbfc9520100f2a0178475ebdf6a4 to your computer and use it in GitHub Desktop.
try:
while True:
pass
time.sleep(1)
except (KeyboardInterrupt, SystemExit):
pass
finally:
if s_th_enable:
s_th.stop()
logging.info('Good bye!')
@simryang
Copy link
Author

It runs endless loop with 'while True:'.
When Ctrl + C is pressed or process received SystemExit signal, it runs part of code 'finally'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment