Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic error when subclassing multiprocessing classes #64094

Closed
anntzer mannequin opened this issue Dec 5, 2013 · 3 comments
Closed

Cryptic error when subclassing multiprocessing classes #64094

anntzer mannequin opened this issue Dec 5, 2013 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Dec 5, 2013

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']

    @anntzer
    Copy link
    Mannequin Author

    anntzer mannequin commented 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:

    >>> 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.

    @anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Dec 5, 2013
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Oct 3, 2014

    @richard have you had any thoughts about this?

    @danoreilly
    Copy link
    Mannequin

    danoreilly mannequin commented Nov 18, 2014

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

    @SilentGhost SilentGhost mannequin closed this as completed Apr 26, 2019
    @SilentGhost SilentGhost mannequin added the type-bug An unexpected behavior, bug, or error label Apr 26, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants