Only call the function in separate thread when in the main loop

This commit is contained in:
shortcutme 2019-12-17 14:48:11 +01:00
parent 8a5a75e68f
commit 3309489c24
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -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