mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
kill threads with subprocesses on exit
This commit is contained in:
parent
565c43971c
commit
bfa61e2e98
3 changed files with 15 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import sys
|
|||
import signal
|
||||
import socket
|
||||
import argparse
|
||||
import atexit
|
||||
import time
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
|
@ -153,6 +154,18 @@ def main_loop(ftrack_url, username, api_key, event_paths):
|
|||
printed_ftrack_error = False
|
||||
printed_mongo_error = False
|
||||
|
||||
def on_exit():
|
||||
if processor_thread is not None:
|
||||
processor_thread.stop()
|
||||
processor_thread.join()
|
||||
processor_thread = None
|
||||
|
||||
if storer_thread is not None:
|
||||
storer_thread.stop()
|
||||
storer_thread.join()
|
||||
storer_thread = None
|
||||
|
||||
atexit.register(on_exit)
|
||||
# Main loop
|
||||
while True:
|
||||
# Check if accessible Ftrack and Mongo url
|
||||
|
|
|
|||
|
|
@ -46,4 +46,4 @@ if __name__ == "__main__":
|
|||
if hasattr(signal, "SIGKILL"):
|
||||
signal.signal(signal.SIGKILL, signal_handler)
|
||||
|
||||
main(sys.argv)
|
||||
sys.exit(main(sys.argv))
|
||||
|
|
|
|||
|
|
@ -105,4 +105,4 @@ if __name__ == "__main__":
|
|||
if hasattr(signal, "SIGKILL"):
|
||||
signal.signal(signal.SIGKILL, signal_handler)
|
||||
|
||||
main(sys.argv)
|
||||
sys.exit(main(sys.argv))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue