[New-bugs-announce] [issue19895] Cryptic error when subclassing multiprocessing classes

Antony Lee report at bugs.python.org
Thu Dec 5 11:35:46 CET 2013


New submission from Antony Lee:

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
>>> class Q(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
>>> class Q(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.

----------
components: Library (Lib)
messages: 205286
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Cryptic error when subclassing multiprocessing classes
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19895>
_______________________________________


More information about the New-bugs-announce mailing list