New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-35917: Test multiprocessing manager classes and shareable types #11772
Conversation
PR titles must begin with the bpo number when there is one. Note issue-number check to allow merge. This automatically generates link in details and listing of PR on the issue. I changed rest so not too long. A news item is also required. Use blurb. (Both checks can be over-ridden by labels, but these are used rarely, for things such as typo fixes.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_multiprocessing_forkserver
and test_multiprocessing_spawn
fail with a lot of errors here. You might try it for yourself:
./python -m test -m "*Manager*" -v test_multiprocessing_forkserver
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be poked with soft cushions! |
…lated hacks performed in install_tests_in_module_dict()
…g install_tests_in_module_dict()
OK, it appears failures on Windows are fixed. |
Hmm, I don't think this is the right solution. You must keep the tests inside For example: @classmethod
def _test_event(cls, obj):
assert obj.is_set()
obj.wait()
obj.clear()
obj.wait(0.001)
def test_event(self):
o = self.manager.Event()
o.set()
self.run_test(self._test_event, o)
assert not o.is_set()
o.wait(0.001) |
…der to make the worker object accessible/serializable on Windows
@giampaolo I think you misunderstood the test failures. A RLock can only be released by the thread/process which acquired it. Example: >>> import threading
>>> lock = threading.RLock()
>>> lock.acquire()
True
>>> t = threading.Thread(target=lock.release)
>>> t.start()
Exception in thread Thread-1990:
Traceback (most recent call last):
File "/home/antoine/miniconda3/envs/pyarrow/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/antoine/miniconda3/envs/pyarrow/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
RuntimeError: cannot release un-acquired lock Same with multiprocessing: >>> lock = mp.RLock()
>>> lock.acquire()
True
>>> proc = mp.Process(target=lock.release)
>>> proc.start()
Process Process-1:
>>> Traceback (most recent call last):
File "/home/antoine/miniconda3/envs/pyarrow/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/home/antoine/miniconda3/envs/pyarrow/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
AssertionError: attempt to release recursive lock not owned by thread So you should write the RLock and Condition tests differently. |
Thanks Antoine. That was the problem indeed (got tricked by the fact that for some reason Linux behaves differently). Good to merge? |
It's actually a bit weird that Linux behaves differently. Can you open an issue for that? |
Thanks @giampaolo for the PR, and @pitrou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, @giampaolo and @pitrou, I could not cleanly backport this to |
GH-11780 is a backport of this pull request to the 3.7 branch. |
…ypes (pythonGH-11772) multiprocessing: provide unittests for manager classes and shareable types. (cherry picked from commit 2848d9d) Co-authored-by: Giampaolo Rodola <g.rodola@gmail.com>
Will do. Do you think we should backport this to 3.7 only? Or also for previous releases? |
3.7 only. Backporting to 2.7 would probably be more involved. |
This PR broke some buildbots with refleak checks because the tests modify the environment (leaking processes or threads or files ...). Some of the failures: https://buildbot.python.org/all/#builders/80/builds/506 I opened https://bugs.python.org/issue35940 to track this. I think I can find some time tonight to check if I am able to find out where the problem is. |
Related to PR #11664. BPO reference is: https://bugs.python.org/issue35917.
https://bugs.python.org/issue35917
Tests can be run with
./python -m test -v _test_multiprocessing
.