This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch tristan/fix-concurrent-blocking-activity in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 0e4107bbf81a269fb03ec597085d058088065899 Author: Tristan van Berkom <[email protected]> AuthorDate: Sat Mar 20 22:40:12 2021 +0900 plugin.py: Avoid import errors on certain platforms In some cases (on Debian with python 3.9 it has been seen) when multiple threads enter the Plugin.blocking_activity() context manager simultaneously, we get ImportErrors from the multiprocessing submodules complaining that we are importing symbols from partially initialized submodules (hinting at possible circular imports). Ensuring that these submodules have been initialized up front circumvents these edge case stack trace bugs from occurring. --- src/buildstream/plugin.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py index f980056..6b3a9f9 100644 --- a/src/buildstream/plugin.py +++ b/src/buildstream/plugin.py @@ -110,7 +110,21 @@ Class Reference """ import itertools + +# +# In some cases (on Debian with python 3.9 it has been seen) when multiple threads +# enter the Plugin.blocking_activity() context manager simultaneously, we get ImportErrors +# from the multiprocessing submodules complaining that we are importing symbols from +# partially initialized submodules (hinting at possible circular imports). +# +# Ensuring that these submodules have been initialized up front circumvents these edge +# case stack trace bugs from occurring. +# import multiprocessing +import multiprocessing.queues +import multiprocessing.synchronize +import multiprocessing.popen_forkserver + import os import pickle import queue
