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 <rep...@bugs.python.org>
<http://bugs.python.org/issue19895>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to