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

Runner: let multiprocessing module choose the context type

It was noticed during a review that, even though the SimpleQueue
requires a context on Python 3, the multiprocessing module can choose
one itself.

Since I originally had no intention to force the `spawn` type of
context, let's use that instead.  Also, since we're using different
names for a helper function and the class, one of the inspekt/pylint
exceptions is not needed anymore.

Kudos to Amador Pahim for suggesting that.

Reference: https://github.com/avocado-framework/avocado/pull/2441#discussion_r167850053Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 9567873e
......@@ -18,7 +18,7 @@ Test runner module.
"""
import multiprocessing
from multiprocessing import queues
import multiprocessing.queues
import os
import signal
import sys
......@@ -579,12 +579,12 @@ class TestRunner(object):
if self.job.sysinfo is not None:
self.job.sysinfo.start_job_hook()
# 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
# Python 3 can choose a context type for queues, but SimpleQueue
# lives directly under the module namespace
if hasattr(multiprocessing, 'SimpleQueue'):
queue = multiprocessing.SimpleQueue()
else:
queue = queues.SimpleQueue() # pylint: disable=E1125
queue = multiprocessing.queues.SimpleQueue() # pylint: disable=E1125
if timeout > 0:
deadline = time.time() + timeout
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册