From 9521804529d78b5f8731ee9110fae1f97f30b9f8 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 19 Oct 2020 17:23:39 +0100 Subject: [PATCH] Stop ThreadPool on exit If we don't do this then we end up delaying shutdown by ~30s. --- s3_storage_provider.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/s3_storage_provider.py b/s3_storage_provider.py index 3f399f7..ef4eaab 100644 --- a/s3_storage_provider.py +++ b/s3_storage_provider.py @@ -82,6 +82,13 @@ class S3StorageProviderBackend(StorageProvider): ) self._download_pool.start() + # Manually stop the thread pool on shutdown. If we don't do this then + # stopping Synapse takes an extra ~30s as Python waits for the threads + # to exit. + reactor.addSystemEventTrigger( + "during", "shutdown", self._download_pool.stop, + ) + def store_file(self, path, file_info): """See StorageProvider.store_file"""