classification
Title: Cryptic error when subclassing multiprocessing classes
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: multiprocessing.JoinableQueue requires new kwarg
View: 21367
Assigned To: Nosy List: dan.oreilly, sbt
Priority: normal Keywords:

Created on 2013-12-05 10:35 by Antony.Lee, last changed 2019-04-26 19:39 by SilentGhost. This issue is now closed.

Messages (3)
msg205286 - (view) Author: Antony Lee (Antony.Lee) * Date: 2013-12-05 10:35
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.
msg228410 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-10-03 23:20
@Richard have you had any thoughts about this?
msg231306 - (view) Author: Dan O'Reilly (dan.oreilly) * Date: 2014-11-18 03:33
This is basically the same thing that issue21367 is reporting.
History
Date User Action Args
2019-04-26 19:39:46SilentGhostsetstatus: open -> closed
type: behavior
superseder: multiprocessing.JoinableQueue requires new kwarg
resolution: duplicate
stage: resolved
2019-04-26 18:06:11Antony.Leesetnosy: - Antony.Lee
2019-04-26 17:31:31BreamoreBoysetnosy: - BreamoreBoy
2016-05-01 13:29:11berker.peksaglinkissue21367 superseder
2014-11-18 03:33:14dan.oreillysetnosy: + dan.oreilly
messages: + msg231306
2014-10-03 23:20:15BreamoreBoysetnosy: + BreamoreBoy

messages: + msg228410
versions: + Python 3.5
2013-12-05 11:41:06pitrousetnosy: + sbt
2013-12-05 10:35:46Antony.Leecreate