Source code for ftrack_connect.asynchronous

# :coding: utf-8
# :copyright: Copyright (c) 2014 ftrack

import threading
import sys

[docs]def asynchronous(method): '''Decorator to make a method asynchronous using its own thread.''' def wrapper(*args, **kwargs): '''Thread wrapped method.''' def exceptHookWrapper(*args, **kwargs): '''Wrapp method and pass exceptions to global excepthook. This is needed in threads because of ''' try: method(*args, **kwargs) except (KeyboardInterrupt, SystemExit): raise except: sys.excepthook(*sys.exc_info()) thread = threading.Thread( target=exceptHookWrapper, args=args, kwargs=kwargs ) thread.start() return wrapper