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

multiprocessing.Connection endianness issue #57205

Closed
neologix mannequin opened this issue Sep 16, 2011 · 4 comments
Closed

multiprocessing.Connection endianness issue #57205

neologix mannequin opened this issue Sep 16, 2011 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@neologix
Copy link
Mannequin

neologix mannequin commented Sep 16, 2011

BPO 12996
Nosy @vstinner
Files
  • multiprocessing_conn_endianness.diff
  • 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 2011-09-20.18:27:21.798>
    created_at = <Date 2011-09-16.18:40:54.501>
    labels = ['type-bug', 'library']
    title = 'multiprocessing.Connection endianness issue'
    updated_at = <Date 2011-09-20.18:27:21.797>
    user = 'https://bugs.python.org/neologix'

    bugs.python.org fields:

    activity = <Date 2011-09-20.18:27:21.797>
    actor = 'neologix'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-09-20.18:27:21.798>
    closer = 'neologix'
    components = ['Library (Lib)']
    creation = <Date 2011-09-16.18:40:54.501>
    creator = 'neologix'
    dependencies = []
    files = ['23171']
    hgrepos = []
    issue_num = 12996
    keywords = ['patch', 'needs review']
    message_count = 4.0
    messages = ['144148', '144236', '144239', '144342']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'neologix', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue12996'
    versions = ['Python 3.3']

    @neologix
    Copy link
    Mannequin Author

    neologix mannequin commented Sep 16, 2011

    Since the rewrite in pure Python of multiprocessing.Connection (issue bpo-11743), multiprocessing.Connection sends and receives the length of the data (used as header) in host byte order.
    This will break if the connection's endpoints are on machine with different endianness.
    Patch attached (it also removes an unnecessary computation of the length of the data being sent).

    @neologix neologix mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 16, 2011
    @vstinner
    Copy link
    Member

    "Since the rewrite in pure Python of multiprocessing.Connection (issue bpo-11743), multiprocessing.Connection sends and receives the length of the data (used as header) in host byte order."

    I don't think so, the C code uses also the host endian. This issue is a feature request.

    I don't know if anyone uses multiprocessing on different hosts (because it doesn't work currently).

    If you would like to support using multiprocessing on different hosts, it should be documented in multiprocessing doc.

    @neologix
    Copy link
    Mannequin Author

    neologix mannequin commented Sep 18, 2011

    "Since the rewrite in pure Python of multiprocessing.Connection (issue bpo-11743), multiprocessing.Connection sends and receives the length of the data (used as header) in host byte order."

    I don't think so, the C code uses also the host endian. This issue is a feature request.

    No.
    http://hg.python.org/cpython/file/5deecc04b7a2/Modules/_multiprocessing/socket_connection.c
    In conn_send_string():
    """
    /* The "header" of the message is a 32 bit unsigned number (in
    network order) which specifies the length of the "body". If
    the message is shorter than about 16kb then it is quicker to
    combine the "header" and the "body" of the message and send
    them at once. */
    [...]
    *(UINT32*)message = htonl((UINT32)length);
    """

    in conn_recv_string():
    """
    ulength = ntohl(ulength);
    """

    I don't know if anyone uses multiprocessing on different hosts (because it doesn't work currently).

    If you would like to support using multiprocessing on different hosts, it should be documented in multiprocessing doc.

    It does work, it's even documented ;-)

    http://docs.python.org/dev/library/multiprocessing.html#multiprocessing-managers
    """
    A manager object returned by Manager() controls a server process which
    holds Python objects and allows other processes to manipulate them
    using proxies.
    [...]
    Server process managers are more flexible than using shared memory
    objects because they can be made to support arbitrary object types.
    Also, a single manager can be shared by processes on different
    computers over a network. They are, however, slower than using shared
    memory.
    """

    Managers use multiprocessing.connection to serialize data and send
    them over a socket:
    http://hg.python.org/cpython/file/5deecc04b7a2/Lib/multiprocessing/managers.py
    """

    # Mapping from serializer name to Listener and Client types

    listener_client = {
    'pickle' : (connection.Listener, connection.Client),
    'xmlrpclib' : (connection.XmlListener, connection.XmlClient)
    }
    """

    Yeah, Python's awesome :-)

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 20, 2011

    New changeset 9c1c81d24e23 by Charles-François Natali in branch 'default':
    Issue bpo-12996: multiprocessing.connection: transmit the header in network byte
    http://hg.python.org/cpython/rev/9c1c81d24e23

    @neologix neologix mannequin closed this as completed Sep 20, 2011
    @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

    1 participant