From e8406df0c7f65212f9dc305daf4f0075e50ac665 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Fri, 25 Feb 2011 22:07:43 +0000 Subject: Issue #6064: Add a `daemon` keyword argument to the threading.Thread and multiprocessing.Process constructors in order to override the default behaviour of inheriting the daemonic property from the current thread/process. --- Lib/test/test_multiprocessing.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 465a83102e..d154fce98a 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -163,6 +163,18 @@ class _TestProcess(BaseTestCase): self.assertEqual(current.ident, os.getpid()) self.assertEqual(current.exitcode, None) + def test_daemon_argument(self): + if self.TYPE == "threads": + return + + # By default uses the current process's daemon flag. + proc0 = self.Process(target=self._test) + self.assertEquals(proc0.daemon, self.current_process().daemon) + proc1 = self.Process(target=self._test, daemon=True) + self.assertTrue(proc1.daemon) + proc2 = self.Process(target=self._test, daemon=False) + self.assertFalse(proc2.daemon) + @classmethod def _test(cls, q, *args, **kwds): current = cls.current_process() -- cgit v1.2.1 From 506482cce4a033d46aa95f1db934d7257990ded0 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 2 Mar 2011 00:15:44 +0000 Subject: assertEquals is deprecated --- Lib/test/test_multiprocessing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index d154fce98a..6f36c19ceb 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -169,7 +169,7 @@ class _TestProcess(BaseTestCase): # By default uses the current process's daemon flag. proc0 = self.Process(target=self._test) - self.assertEquals(proc0.daemon, self.current_process().daemon) + self.assertEqual(proc0.daemon, self.current_process().daemon) proc1 = self.Process(target=self._test, daemon=True) self.assertTrue(proc1.daemon) proc2 = self.Process(target=self._test, daemon=False) -- cgit v1.2.1 From 41224435f0695630a8df433ed28a65d5bb74e0c3 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 9 May 2011 17:04:27 +0200 Subject: Issue #11743: Rewrite multiprocessing connection classes in pure Python. --- Lib/test/test_multiprocessing.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index a7f0391dab..0c05ff63a1 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1915,9 +1915,15 @@ class TestInvalidHandle(unittest.TestCase): @unittest.skipIf(WIN32, "skipped on Windows") def test_invalid_handles(self): - conn = _multiprocessing.Connection(44977608) - self.assertRaises(IOError, conn.poll) - self.assertRaises(IOError, _multiprocessing.Connection, -1) + conn = multiprocessing.connection.Connection(44977608) + try: + self.assertRaises((ValueError, IOError), conn.poll) + finally: + # Hack private attribute _handle to avoid printing an error + # in conn.__del__ + conn._handle = None + self.assertRaises((ValueError, IOError), + multiprocessing.connection.Connection, -1) # # Functions used to create test cases from the base ones in this module -- cgit v1.2.1 From c67742818cff89d360c3bcceebe6e388b951b72c Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 6 Jun 2011 19:35:31 +0200 Subject: Issue #12040: Expose a new attribute `sentinel` on instances of :class:`multiprocessing.Process`. Also, fix Process.join() to not use polling anymore, when given a timeout. --- Lib/test/test_multiprocessing.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 0c05ff63a1..85094cc5f4 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -71,6 +71,23 @@ HAVE_GETVALUE = not getattr(_multiprocessing, 'HAVE_BROKEN_SEM_GETVALUE', False) WIN32 = (sys.platform == "win32") +if WIN32: + from _subprocess import WaitForSingleObject, INFINITE, WAIT_OBJECT_0 + + def wait_for_handle(handle, timeout): + if timeout is None or timeout < 0.0: + timeout = INFINITE + else: + timeout = int(1000 * timeout) + return WaitForSingleObject(handle, timeout) == WAIT_OBJECT_0 +else: + from select import select + _select = util._eintr_retry(select) + + def wait_for_handle(handle, timeout): + if timeout is not None and timeout < 0.0: + timeout = None + return handle in _select([handle], [], [], timeout)[0] # # Some tests require ctypes @@ -307,6 +324,26 @@ class _TestProcess(BaseTestCase): ] self.assertEqual(result, expected) + @classmethod + def _test_sentinel(cls, event): + event.wait(10.0) + + def test_sentinel(self): + if self.TYPE == "threads": + return + event = self.Event() + p = self.Process(target=self._test_sentinel, args=(event,)) + with self.assertRaises(ValueError): + p.sentinel + p.start() + self.addCleanup(p.join) + sentinel = p.sentinel + self.assertIsInstance(sentinel, int) + self.assertFalse(wait_for_handle(sentinel, timeout=0.0)) + event.set() + p.join() + self.assertTrue(wait_for_handle(sentinel, timeout=DELTA)) + # # # -- cgit v1.2.1 From 967b3b7dad90efd2c9310b8598a80059c79f2213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Tue, 20 Sep 2011 20:36:51 +0200 Subject: Issue #12981: test_multiprocessing: catch ImportError when importing multiprocessing.reduction, which may not be available (e.g. if the OS doesn't support FD passing over Unix domain sockets). --- Lib/test/test_multiprocessing.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 3f8a9a2d35..7ac77e926d 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -35,7 +35,13 @@ import multiprocessing.managers import multiprocessing.heap import multiprocessing.pool -from multiprocessing import util, reduction +from multiprocessing import util + +try: + from multiprocessing import reduction + HAS_REDUCTION = True +except ImportError: + HAS_REDUCTION = False try: from multiprocessing.sharedctypes import Value, copy @@ -1631,6 +1637,7 @@ class _TestConnection(BaseTestCase): os.write(fd, data) os.close(fd) + @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction") def test_fd_transfer(self): if self.TYPE != 'processes': self.skipTest("only makes sense with processes") @@ -1648,6 +1655,7 @@ class _TestConnection(BaseTestCase): with open(test.support.TESTFN, "rb") as f: self.assertEqual(f.read(), b"foo") + @unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction") @unittest.skipIf(sys.platform == "win32", "test semantics don't make sense on Windows") @unittest.skipIf(MAXFD <= 256, @@ -1987,10 +1995,12 @@ class _TestImportStar(BaseTestCase): 'multiprocessing', 'multiprocessing.connection', 'multiprocessing.heap', 'multiprocessing.managers', 'multiprocessing.pool', 'multiprocessing.process', - 'multiprocessing.reduction', 'multiprocessing.synchronize', 'multiprocessing.util' ] + if HAS_REDUCTION: + modules.append('multiprocessing.reduction') + if c_int is not None: # This module requires _ctypes modules.append('multiprocessing.sharedctypes') -- cgit v1.2.1 From 3839f535cf78045ada26f41da77ecbbc5469ab05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Tue, 22 Nov 2011 18:55:22 +0100 Subject: Issue #12156: Skip test_multiprocessing on systems which don't support enough POSIX semaphores (among which FreeBSD < 8). --- Lib/test/test_multiprocessing.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 0bc056fec1..b99201b280 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -115,6 +115,22 @@ except ImportError: Structure = object c_int = c_double = None + +def check_enough_semaphores(): + """Check that the system supports enough semaphores to run the test.""" + # minimum number of semaphores available according to POSIX + nsems_min = 256 + try: + nsems = os.sysconf("SC_SEM_NSEMS_MAX") + except (AttributeError, ValueError): + # sysconf not available or setting not available + return + if nsems == -1 or nsems >= nsems_min: + return + raise unittest.SkipTest("The OS doesn't support enough semaphores " + "to run the test (required: %d)." % nsems_min) + + # # Creates a wrapper for a function which records the time it takes to finish # @@ -2349,6 +2365,8 @@ def test_main(run=None): except OSError: raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!") + check_enough_semaphores() + if run is None: from test.support import run_unittest as run -- cgit v1.2.1 From 56ec2a8ca7b4c9c27b6714cb3f82e13030e0b240 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 21 Dec 2011 11:03:24 +0100 Subject: Issue #12708: Add starmap() and starmap_async() methods (similar to itertools.starmap()) to multiprocessing.Pool. Patch by Hynek Schlawack. --- Lib/test/test_multiprocessing.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index b99201b280..93cc11d96d 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -8,6 +8,7 @@ import unittest import queue as pyqueue import time import io +import itertools import sys import os import gc @@ -1125,6 +1126,9 @@ def sqr(x, wait=0.0): time.sleep(wait) return x*x +def mul(x, y): + return x*y + class _TestPool(BaseTestCase): def test_apply(self): @@ -1138,6 +1142,20 @@ class _TestPool(BaseTestCase): self.assertEqual(pmap(sqr, list(range(100)), chunksize=20), list(map(sqr, list(range(100))))) + def test_starmap(self): + psmap = self.pool.starmap + tuples = list(zip(range(10), range(9,-1, -1))) + self.assertEqual(psmap(mul, tuples), + list(itertools.starmap(mul, tuples))) + tuples = list(zip(range(100), range(99,-1, -1))) + self.assertEqual(psmap(mul, tuples, chunksize=20), + list(itertools.starmap(mul, tuples))) + + def test_starmap_async(self): + tuples = list(zip(range(100), range(99,-1, -1))) + self.assertEqual(self.pool.starmap_async(mul, tuples).get(), + list(itertools.starmap(mul, tuples))) + def test_map_chunksize(self): try: self.pool.map_async(sqr, [], chunksize=1).get(timeout=TIMEOUT1) -- cgit v1.2.1 From 818356540ccf1fb471e371ce68951e5638a9bdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Fran=C3=A7ois=20Natali?= Date: Wed, 8 Feb 2012 21:15:58 +0100 Subject: Issue #8184: multiprocessing: On Windows, don't set SO_REUSEADDR on Connection sockets, and set FILE_FLAG_FIRST_PIPE_INSTANCE on named pipes, to make sure two listeners can't bind to the same socket/pipe (or any existing socket/pipe). --- Lib/test/test_multiprocessing.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index e5beb97a0b..f141bd4e48 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1779,6 +1779,17 @@ class _TestConnection(BaseTestCase): self.assertRaises(RuntimeError, reduction.recv_handle, conn) p.join() +class _TestListener(BaseTestCase): + + ALLOWED_TYPES = ('processes') + + def test_multiple_bind(self): + for family in self.connection.families: + l = self.connection.Listener(family=family) + self.addCleanup(l.close) + self.assertRaises(OSError, self.connection.Listener, + l.address, family) + class _TestListenerClient(BaseTestCase): ALLOWED_TYPES = ('processes', 'threads') @@ -1799,6 +1810,7 @@ class _TestListenerClient(BaseTestCase): self.assertEqual(conn.recv(), 'hello') p.join() l.close() + # # Test of sending connection and socket objects between processes # -- cgit v1.2.1 From 0e0ccbf2431f5e426916ed2b9ae083c6244285a5 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Mon, 5 Mar 2012 19:28:37 +0100 Subject: Issue #12328: Fix multiprocessing's use of overlapped I/O on Windows. Also, add a multiprocessing.connection.wait(rlist, timeout=None) function for polling multiple objects at once. Patch by sbt. Complete changelist from sbt's patch: * Adds a wait(rlist, timeout=None) function for polling multiple objects at once. On Unix this is just a wrapper for select(rlist, [], [], timeout=None). * Removes use of the SentinelReady exception and the sentinels argument to certain methods. concurrent.futures.process has been changed to use wait() instead of SentinelReady. * Fixes bugs concerning PipeConnection.poll() and messages of zero length. * Fixes PipeListener.accept() to call ConnectNamedPipe() with overlapped=True. * Fixes Queue.empty() and SimpleQueue.empty() so that they are threadsafe on Windows. * Now PipeConnection.poll() and wait() will not modify the pipe except possibly by consuming a zero length message. (Previously poll() could consume a partial message.) * All of multiprocesing's pipe related blocking functions/methods are now interruptible by SIGINT on Windows. --- Lib/test/test_multiprocessing.py | 235 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 234 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index f141bd4e48..35d85d75e5 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1811,6 +1811,84 @@ class _TestListenerClient(BaseTestCase): p.join() l.close() +class _TestPoll(unittest.TestCase): + + ALLOWED_TYPES = ('processes', 'threads') + + def test_empty_string(self): + a, b = self.Pipe() + self.assertEqual(a.poll(), False) + b.send_bytes(b'') + self.assertEqual(a.poll(), True) + self.assertEqual(a.poll(), True) + + @classmethod + def _child_strings(cls, conn, strings): + for s in strings: + time.sleep(0.1) + conn.send_bytes(s) + conn.close() + + def test_strings(self): + strings = (b'hello', b'', b'a', b'b', b'', b'bye', b'', b'lop') + a, b = self.Pipe() + p = self.Process(target=self._child_strings, args=(b, strings)) + p.start() + + for s in strings: + for i in range(200): + if a.poll(0.01): + break + x = a.recv_bytes() + self.assertEqual(s, x) + + p.join() + + @classmethod + def _child_boundaries(cls, r): + # Polling may "pull" a message in to the child process, but we + # don't want it to pull only part of a message, as that would + # corrupt the pipe for any other processes which might later + # read from it. + r.poll(5) + + def test_boundaries(self): + r, w = self.Pipe(False) + p = self.Process(target=self._child_boundaries, args=(r,)) + p.start() + time.sleep(2) + L = [b"first", b"second"] + for obj in L: + w.send_bytes(obj) + w.close() + p.join() + self.assertIn(r.recv_bytes(), L) + + @classmethod + def _child_dont_merge(cls, b): + b.send_bytes(b'a') + b.send_bytes(b'b') + b.send_bytes(b'cd') + + def test_dont_merge(self): + a, b = self.Pipe() + self.assertEqual(a.poll(0.0), False) + self.assertEqual(a.poll(0.1), False) + + p = self.Process(target=self._child_dont_merge, args=(b,)) + p.start() + + self.assertEqual(a.recv_bytes(), b'a') + self.assertEqual(a.poll(1.0), True) + self.assertEqual(a.poll(1.0), True) + self.assertEqual(a.recv_bytes(), b'b') + self.assertEqual(a.poll(1.0), True) + self.assertEqual(a.poll(1.0), True) + self.assertEqual(a.poll(0.0), True) + self.assertEqual(a.recv_bytes(), b'cd') + + p.join() + # # Test of sending connection and socket objects between processes # @@ -2404,8 +2482,163 @@ class TestStdinBadfiledescriptor(unittest.TestCase): flike.flush() assert sio.getvalue() == 'foo' + +class TestWait(unittest.TestCase): + + @classmethod + def _child_test_wait(cls, w, slow): + for i in range(10): + if slow: + time.sleep(random.random()*0.1) + w.send((i, os.getpid())) + w.close() + + def test_wait(self, slow=False): + from multiprocessing import Pipe, Process + from multiprocessing.connection import wait + readers = [] + procs = [] + messages = [] + + for i in range(4): + r, w = Pipe(duplex=False) + p = Process(target=self._child_test_wait, args=(w, slow)) + p.daemon = True + p.start() + w.close() + readers.append(r) + procs.append(p) + + while readers: + for r in wait(readers): + try: + msg = r.recv() + except EOFError: + readers.remove(r) + r.close() + else: + messages.append(msg) + + messages.sort() + expected = sorted((i, p.pid) for i in range(10) for p in procs) + self.assertEqual(messages, expected) + + @classmethod + def _child_test_wait_socket(cls, address, slow): + s = socket.socket() + s.connect(address) + for i in range(10): + if slow: + time.sleep(random.random()*0.1) + s.sendall(('%s\n' % i).encode('ascii')) + s.close() + + def test_wait_socket(self, slow=False): + from multiprocessing import Process + from multiprocessing.connection import wait + l = socket.socket() + l.bind(('', 0)) + l.listen(4) + addr = ('localhost', l.getsockname()[1]) + readers = [] + procs = [] + dic = {} + + for i in range(4): + p = Process(target=self._child_test_wait_socket, args=(addr, slow)) + p.daemon = True + p.start() + procs.append(p) + + for i in range(4): + r, _ = l.accept() + readers.append(r) + dic[r] = [] + l.close() + + while readers: + for r in wait(readers): + msg = r.recv(32) + if not msg: + readers.remove(r) + r.close() + else: + dic[r].append(msg) + + expected = ''.join('%s\n' % i for i in range(10)).encode('ascii') + for v in dic.values(): + self.assertEqual(b''.join(v), expected) + + def test_wait_slow(self): + self.test_wait(True) + + def test_wait_socket_slow(self): + self.test_wait(True) + + def test_wait_timeout(self): + from multiprocessing.connection import wait + + expected = 1 + a, b = multiprocessing.Pipe() + + start = time.time() + res = wait([a, b], 1) + delta = time.time() - start + + self.assertEqual(res, []) + self.assertLess(delta, expected + 0.2) + self.assertGreater(delta, expected - 0.2) + + b.send(None) + + start = time.time() + res = wait([a, b], 1) + delta = time.time() - start + + self.assertEqual(res, [a]) + self.assertLess(delta, 0.2) + + def test_wait_integer(self): + from multiprocessing.connection import wait + + expected = 5 + a, b = multiprocessing.Pipe() + p = multiprocessing.Process(target=time.sleep, args=(expected,)) + + p.start() + self.assertIsInstance(p.sentinel, int) + + start = time.time() + res = wait([a, p.sentinel, b], expected + 20) + delta = time.time() - start + + self.assertEqual(res, [p.sentinel]) + self.assertLess(delta, expected + 1) + self.assertGreater(delta, expected - 1) + + a.send(None) + + start = time.time() + res = wait([a, p.sentinel, b], 20) + delta = time.time() - start + + self.assertEqual(res, [p.sentinel, b]) + self.assertLess(delta, 0.2) + + b.send(None) + + start = time.time() + res = wait([a, p.sentinel, b], 20) + delta = time.time() - start + + self.assertEqual(res, [a, p.sentinel, b]) + self.assertLess(delta, 0.2) + + p.join() + + testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, - TestStdinBadfiledescriptor] + TestStdinBadfiledescriptor, TestWait] # # -- cgit v1.2.1 From cd2368abcd5d36fa68134216a0d5a8b9fad43b0b Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 6 Mar 2012 13:42:35 +0100 Subject: Reap processes at test end to avoid false positives in reference leak detection. --- Lib/test/test_multiprocessing.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 35d85d75e5..07843f98b8 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2508,6 +2508,7 @@ class TestWait(unittest.TestCase): w.close() readers.append(r) procs.append(p) + self.addCleanup(p.join) while readers: for r in wait(readers): @@ -2549,6 +2550,7 @@ class TestWait(unittest.TestCase): p.daemon = True p.start() procs.append(p) + self.addCleanup(p.join) for i in range(4): r, _ = l.accept() -- cgit v1.2.1 From 4f1142caf1aaf5f7c3ed5a1f56dcb28c3b22c8d8 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 6 Mar 2012 13:43:24 +0100 Subject: Remove a couple of local imports. --- Lib/test/test_multiprocessing.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 07843f98b8..0db6352e32 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2494,15 +2494,14 @@ class TestWait(unittest.TestCase): w.close() def test_wait(self, slow=False): - from multiprocessing import Pipe, Process from multiprocessing.connection import wait readers = [] procs = [] messages = [] for i in range(4): - r, w = Pipe(duplex=False) - p = Process(target=self._child_test_wait, args=(w, slow)) + r, w = multiprocessing.Pipe(duplex=False) + p = multiprocessing.Process(target=self._child_test_wait, args=(w, slow)) p.daemon = True p.start() w.close() @@ -2535,7 +2534,6 @@ class TestWait(unittest.TestCase): s.close() def test_wait_socket(self, slow=False): - from multiprocessing import Process from multiprocessing.connection import wait l = socket.socket() l.bind(('', 0)) @@ -2546,7 +2544,8 @@ class TestWait(unittest.TestCase): dic = {} for i in range(4): - p = Process(target=self._child_test_wait_socket, args=(addr, slow)) + p = multiprocessing.Process(target=self._child_test_wait_socket, + args=(addr, slow)) p.daemon = True p.start() procs.append(p) -- cgit v1.2.1 From a36aafc6c444bb7ced846cd13f9e14c0181ec471 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Fri, 9 Mar 2012 18:40:15 +0100 Subject: Relax timeout tests for weak Windows buildbot --- Lib/test/test_multiprocessing.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Lib/test/test_multiprocessing.py') diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 0db6352e32..d65cf6e1af 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -2587,8 +2587,8 @@ class TestWait(unittest.TestCase): delta = time.time() - start self.assertEqual(res, []) - self.assertLess(delta, expected + 0.2) - self.assertGreater(delta, expected - 0.2) + self.assertLess(delta, expected + 0.5) + self.assertGreater(delta, expected - 0.5) b.send(None) @@ -2597,7 +2597,7 @@ class TestWait(unittest.TestCase): delta = time.time() - start self.assertEqual(res, [a]) - self.assertLess(delta, 0.2) + self.assertLess(delta, 0.4) def test_wait_integer(self): from multiprocessing.connection import wait @@ -2614,8 +2614,8 @@ class TestWait(unittest.TestCase): delta = time.time() - start self.assertEqual(res, [p.sentinel]) - self.assertLess(delta, expected + 1) - self.assertGreater(delta, expected - 1) + self.assertLess(delta, expected + 2) + self.assertGreater(delta, expected - 2) a.send(None) @@ -2624,7 +2624,7 @@ class TestWait(unittest.TestCase): delta = time.time() - start self.assertEqual(res, [p.sentinel, b]) - self.assertLess(delta, 0.2) + self.assertLess(delta, 0.4) b.send(None) @@ -2633,7 +2633,7 @@ class TestWait(unittest.TestCase): delta = time.time() - start self.assertEqual(res, [a, p.sentinel, b]) - self.assertLess(delta, 0.2) + self.assertLess(delta, 0.4) p.join() -- cgit v1.2.1