2014-10-27 16:29:04 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-01-19 12:15:57 -06:00
|
|
|
import logging
|
|
|
|
log = logging.getLogger("mysc.thread_utils")
|
2014-10-27 16:29:04 -06:00
|
|
|
import threading
|
|
|
|
import wx
|
2015-01-08 08:01:45 -06:00
|
|
|
from pubsub import pub
|
2014-10-27 16:29:04 -06:00
|
|
|
|
|
|
|
def call_threaded(func, *args, **kwargs):
|
2021-06-16 16:18:41 -05:00
|
|
|
#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))
|
2014-10-27 16:29:04 -06:00
|
|
|
# pass
|
2021-06-16 16:18:41 -05:00
|
|
|
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
|
|
|
|
thread.daemon = True
|
|
|
|
thread.start()
|
|
|
|
return thread
|