提交 efb19dec 编写于 作者: C Cleber Rosa

Python 3 port: provide context to SimpleQueue when required

The multiprocessing library in Python 3 has some differences from the
one in Python 2.  One of those, is the requirement of a context for a
SimpleQueue.

Since we're going to use that specific interface (get_context()),
let's check for it, and use it to get a context if it exists.

PS: This approach for checking the interface avoids having an external
library like `six` imported here just for the reason of checking the
Python version.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 aa77bf2e
......@@ -570,7 +570,13 @@ class TestRunner(object):
summary = set()
if self.job.sysinfo is not None:
self.job.sysinfo.start_job_hook()
queue = queues.SimpleQueue()
# Python 3 requires a context for a queue
if hasattr(multiprocessing, 'get_context'):
ctx = multiprocessing.get_context('spawn')
queue = queues.SimpleQueue(ctx=ctx) # pylint: disable=E1123
else:
queue = queues.SimpleQueue()
if timeout > 0:
deadline = time.time() + timeout
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册