[Zhihao Yuan] ability to run a function in a thread without calling a callback.
This commit is contained in:
parent
08020a310c
commit
6773c63cf6
|
@ -2899,13 +2899,14 @@ class PassphraseRequest:
|
|||
|
||||
|
||||
class ThreadInterface:
|
||||
def __init__(self, func, func_args, callback, callback_args):
|
||||
def __init__(self, func, func_args=(), callback=None, callback_args=()):
|
||||
"""
|
||||
Call a function in a thread
|
||||
"""
|
||||
def thread_function(func, func_args, callback, callback_args):
|
||||
output = func(*func_args)
|
||||
gobject.idle_add(callback, output, *callback_args)
|
||||
if callback:
|
||||
gobject.idle_add(callback, output, *callback_args)
|
||||
|
||||
Thread(target=thread_function, args=(func, func_args, callback,
|
||||
callback_args)).start()
|
||||
|
|
Loading…
Reference in New Issue