From 3309489c247ba8333e3694a339d11d8104fa77c8 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Tue, 17 Dec 2019 14:48:11 +0100 Subject: [PATCH] Only call the function in separate thread when in the main loop --- src/util/ThreadPool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/ThreadPool.py b/src/util/ThreadPool.py index 3ed39d61..f11ca677 100644 --- a/src/util/ThreadPool.py +++ b/src/util/ThreadPool.py @@ -27,7 +27,9 @@ class ThreadPool: return func def wrapper(*args, **kwargs): - res = self.pool.apply(func, args, kwargs) + if not isMainThread(): # Call directly if not in main thread + return func(*args, **kwargs) + res = self.apply(func, args, kwargs) return res return wrapper