You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cryptic error when subclassing multiprocessing classes #64094
Classes defined in the multiprocessing module are in fact functions that call the internally defined class constructor with the "ctx" argument properly set; because of that, trying to subclass them yields a (very?) cryptic error message:
>>> import multiprocessing as m, multiprocessing.queues as q
>>> classQ(m.Queue): pass# normal attempt fails
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function() argument 1 must be code, not str
>>> classQ(q.Queue): pass# that one works fine
...
I guess the error message here could be improved, and the limitation and the workaround should be mentioned in the docs. Even better would be to have real classes directly in the multiprocessing module rather than wrappers, although I believe that would require sorting out some circular import issues.
Activity
anntzer commentedon Dec 5, 2013
Classes defined in the multiprocessing module are in fact functions that call the internally defined class constructor with the "ctx" argument properly set; because of that, trying to subclass them yields a (very?) cryptic error message:
I guess the error message here could be improved, and the limitation and the workaround should be mentioned in the docs. Even better would be to have real classes directly in the multiprocessing module rather than wrappers, although I believe that would require sorting out some circular import issues.
BreamoreBoy commentedon Oct 3, 2014
@richard have you had any thoughts about this?
danoreilly commentedon Nov 18, 2014
This is basically the same thing that bpo-21367 is reporting.