You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/10 08:27:59 UTC

[incubator-ponymail-foal] 01/05: Switch to threaded pool, let Python decide on worker count

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 2fe14bef3e3b9093500a8a2c0f860013b3328ace
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Sep 10 10:22:41 2020 +0200

    Switch to threaded pool, let Python decide on worker count
---
 server/plugins/offloader.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/server/plugins/offloader.py b/server/plugins/offloader.py
index 4a6b95e..bd38a0e 100644
--- a/server/plugins/offloader.py
+++ b/server/plugins/offloader.py
@@ -24,8 +24,10 @@ DEBUG = False
 
 
 class ExecutorPool:
-    def __init__(self, threads=10):
-        self.threads = concurrent.futures.ProcessPoolExecutor(max_workers=threads)
+    """A pool of runners for offloading blocking processes to threads, so that async processing can continue"""
+    def __init__(self, threads=None):
+        # If no thread count is specified, will default to: min(32, os.cpu_count() + 4)
+        self.threads = concurrent.futures.ThreadPoolExecutor(max_workers=threads)
 
     async def run(self, func, *args, **kwargs):
         if DEBUG: