diff options
author | Charles-François Natali <neologix@free.fr> | 2011-12-20 10:49:25 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-12-20 10:49:25 (GMT) |
commit | 29b15d11bb96a0c83255a49a7ff130f9fc56ad90 (patch) | |
tree | da84763164a52548ce4619504f3f52dcfb4c4d7c /Lib/test/test_mailbox.py | |
parent | 8691bff6db78a45fd89a385401ece64921867500 (diff) | |
parent | bf38315446ad92f9f8e74a3d35d6d7420badf34e (diff) | |
download | cpython-29b15d11bb96a0c83255a49a7ff130f9fc56ad90.zip cpython-29b15d11bb96a0c83255a49a7ff130f9fc56ad90.tar.gz cpython-29b15d11bb96a0c83255a49a7ff130f9fc56ad90.tar.bz2 |
Followup to issue #11867: Use socketpair(), since FreeBSD < 8 doesn't really
support multiprocessing.Event.
Diffstat (limited to 'Lib/test/test_mailbox.py')
-rw-r--r-- | Lib/test/test_mailbox.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py index 67386a5..4bb05a4 100644 --- a/Lib/test/test_mailbox.py +++ b/Lib/test/test_mailbox.py @@ -17,10 +17,6 @@ try: import fcntl except ImportError: pass -try: - import multiprocessing -except ImportError: - multiprocessing = None class TestBase(unittest.TestCase): @@ -998,12 +994,13 @@ class _TestMboxMMDF(TestMailbox): self._box = self._factory(self._path) @unittest.skipUnless(hasattr(os, 'fork'), "Test needs fork().") - @unittest.skipUnless(multiprocessing, "Test needs multiprocessing.") + @unittest.skipUnless(hasattr(socket, 'socketpair'), "Test needs socketpair().") def test_lock_conflict(self): # Fork off a child process that will lock the mailbox temporarily, # unlock it and exit. - ready = multiprocessing.Event() - done = multiprocessing.Event() + c, p = socket.socketpair() + self.addCleanup(c.close) + self.addCleanup(p.close) pid = os.fork() if pid == 0: @@ -1011,22 +1008,22 @@ class _TestMboxMMDF(TestMailbox): try: # lock the mailbox, and signal the parent it can proceed self._box.lock() - ready.set() + c.send(b'c') # wait until the parent is done, and unlock the mailbox - done.wait(5) + c.recv(1) self._box.unlock() finally: os._exit(0) # In the parent, wait until the child signals it locked the mailbox. - ready.wait(5) + p.recv(1) try: self.assertRaises(mailbox.ExternalClashError, self._box.lock) finally: # Signal the child it can now release the lock and exit. - done.set() + p.send(b'p') # Wait for child to exit. Locking should now succeed. exited_pid, status = os.waitpid(pid, 0) |