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
Misleading names for multiprocessing "convenience" functions #47839
Comments
The package level imports from the new multiprocessing package exhibit Python 2.6b1+ (trunk:64945, Jul 14 2008, 20:00:46)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing as mp
>>> isinstance(mp.Lock(), mp.Lock)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes
and types
>>> mp.Lock.__name__
'Lock'
>>> mp.Lock.__module__
'multiprocessing'
>>> mp.Lock().__class__.__name__
'Lock'
>>> mp.Lock().__class__.__module__
'multiprocessing.synchronize' The delayed import functions in multiprocessing.__init__ look like a |
Setting to deferred blocker, since this really needs to be dealt with |
+1 |
Patch attached that removes the misleading "convenience" functions, The patch also adds docstrings to some of the original class definitions No changes were needed to the multiprocessing tests - they all still Python 2.6b3+ (trunk:66083, Aug 31 2008, 19:00:32)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing as mp
>>> isinstance(mp.Lock(), mp.Lock)
True
>>> mp.Lock.__name__
'Lock'
>>> mp.Lock.__module__
'multiprocessing.synchronize' |
Interesting - in some of the other work I was doing regarding the PEP-8 def Event(*args, **kwds):
return _Event(*args, **kwds) Using a factory function to discourage subclassing is one thing, but why |
This is why multiprocessing had them nick - the threading module does On Sep 1, 2008, at 9:07 AM, Nick Coghlan <report@bugs.python.org> wrote:
|
Patch reviewed/tested and I also confirmed that this doesn't affect the |
Reopening, there's a bug that the tests/examples/etc didn't catch (and woot:python-trunk jesse$ ./python.exe
Python 2.6b3+ (trunk:66112:66114M, Sep 1 2008, 13:00:19)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _multiprocessing
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jesse/open_source/subversion/python-
trunk/Lib/multiprocessing/__init__.py", line 148, in <module>
from multiprocessing.synchronize import (Lock, RLock, Condition,
Event,
File "/Users/jesse/open_source/subversion/python-
trunk/Lib/multiprocessing/synchronize.py", line 29, in <module>
SEM_VALUE_MAX = _multiprocessing.SemLock.SEM_VALUE_MAX
AttributeError: 'module' object has no attribute 'SemLock'
>>> |
Ben is backing out the patch now |
Given how long I've been using the threading module without realising it As Fredrik noted in the python-dev thread, the threading versions of |
Sounds good to me. :) |
Le lundi 01 septembre 2008 à 21:22 +0000, Nick Coghlan a écrit :
"Foolish consistency, etc.". :-) |
Not so much "too complicated" as "potentially touches a lot of code and As I noted on python-dev, it's actually a change that can easily be |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: