Skip to content

Cryptic error when subclassing multiprocessing classes #64094

Closed

Description

@anntzer
mannequin
BPO 19895
Superseder
  • bpo-21367: multiprocessing.JoinableQueue requires new kwarg
  • 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:

    assignee = None
    closed_at = <Date 2019-04-26.19:39:46.262>
    created_at = <Date 2013-12-05.10:35:46.117>
    labels = ['type-bug', 'library']
    title = 'Cryptic error when subclassing multiprocessing classes'
    updated_at = <Date 2019-04-26.19:39:46.261>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2019-04-26.19:39:46.261>
    actor = 'SilentGhost'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-04-26.19:39:46.262>
    closer = 'SilentGhost'
    components = ['Library (Lib)']
    creation = <Date 2013-12-05.10:35:46.117>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 19895
    keywords = []
    message_count = 3.0
    messages = ['205286', '228410', '231306']
    nosy_count = 2.0
    nosy_names = ['sbt', 'dan.oreilly']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '21367'
    type = 'behavior'
    url = 'https://bugs.python.org/issue19895'
    versions = ['Python 3.4', 'Python 3.5']

    Activity

    1. anntzer commented on Dec 5, 2013

      anntzermannequin
      MannequinAuthor

      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.

    2. added
      stdlib
      on Dec 5, 2013
    3. BreamoreBoy commented on Oct 3, 2014

      BreamoreBoymannequin
      Mannequin

      @richard have you had any thoughts about this?

    4. danoreilly commented on Nov 18, 2014

      danoreillymannequin
      Mannequin

      This is basically the same thing that bpo-21367 is reporting.

    5. added
      type-bug
      on Apr 26, 2019
    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibtype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions