From 442dcd584b7f77f05d56cff3d42c88460068d592 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 27 Jun 2017 03:18:42 +0200 Subject: [PATCH] Improve executor pool size / speedup python 3.5 (#8215) * Improve executor pool size / speedup python36 * fix style * Add comment --- homeassistant/core.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/core.py b/homeassistant/core.py index cb6c3522496..efdf3338c19 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -48,9 +48,6 @@ SERVICE_CALL_LIMIT = 10 # seconds # Pattern for validating entity IDs (format: .) ENTITY_ID_PATTERN = re.compile(r"^(\w+)\.(\w+)$") -# Size of a executor pool -EXECUTOR_POOL_SIZE = 10 - # How long to wait till things that run on startup have to finish. TIMEOUT_EVENT_START = 15 @@ -114,9 +111,11 @@ class HomeAssistant(object): else: self.loop = loop or asyncio.get_event_loop() - executor_opts = { - 'max_workers': EXECUTOR_POOL_SIZE - } + executor_opts = {'max_workers': 10} + if sys.version_info[:2] >= (3, 5): + # It will default set to the number of processors on the machine, + # multiplied by 5. That is better for overlap I/O workers. + executor_opts['max_workers'] = None if sys.version_info[:2] >= (3, 6): executor_opts['thread_name_prefix'] = 'SyncWorker'