mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-29 22:23:12 -06:00
20 lines
628 B
Python
20 lines
628 B
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
log = logging.getLogger("mysc.thread_utils")
|
|
import threading
|
|
import wx
|
|
from pubsub import pub
|
|
|
|
def call_threaded(func, *args, **kwargs):
|
|
#Call the given function in a daemonized thread and return the thread.
|
|
def new_func(*a, **k):
|
|
try:
|
|
func(*a, **k)
|
|
except:
|
|
log.exception("Thread %d with function %r, args of %r, and kwargs of %r failed to run." % (threading.current_thread().ident, func, a, k))
|
|
# pass
|
|
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
|
thread.daemon = True
|
|
thread.start()
|
|
return thread
|