Skip to content
Snippets Groups Projects
Commit 6773c63c authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

[Zhihao Yuan] ability to run a function in a thread without calling a callback.

parent 08020a31
No related branches found
No related tags found
No related merge requests found
...@@ -2899,13 +2899,14 @@ class PassphraseRequest: ...@@ -2899,13 +2899,14 @@ class PassphraseRequest:
class ThreadInterface: 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 Call a function in a thread
""" """
def thread_function(func, func_args, callback, callback_args): def thread_function(func, func_args, callback, callback_args):
output = func(*func_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, Thread(target=thread_function, args=(func, func_args, callback,
callback_args)).start() callback_args)).start()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment