python / cpython

The Python programming language
https://www.python.org
Other
63.54k stars 30.44k forks source link

multiprocessing module, example code error #51534

Closed f4003412-23b3-41e6-992a-fe93a7a45eb4 closed 14 years ago

f4003412-23b3-41e6-992a-fe93a7a45eb4 commented 15 years ago
BPO 7285
Nosy @birkenfeld, @orsenthil, @sandrotosi
Files
  • multiprocessing.rst.diff: patch to fix errors
  • 7285.patch: applies cleanly to trunk.
  • issue7285-py3k.patch
  • 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: ```python assignee = None closed_at = created_at = labels = ['type-bug', 'docs'] title = 'multiprocessing module, example code error' updated_at = user = 'https://bugs.python.org/hsmtkk' ``` bugs.python.org fields: ```python activity = actor = 'orsenthil' assignee = 'jnoller' closed = True closed_date = closer = 'orsenthil' components = ['Documentation'] creation = creator = 'hsmtkk' dependencies = [] files = ['15288', '15374', '19151'] hgrepos = [] issue_num = 7285 keywords = ['patch'] message_count = 3.0 messages = ['95035', '118130', '118307'] nosy_count = 5.0 nosy_names = ['georg.brandl', 'orsenthil', 'jnoller', 'hsmtkk', 'sandro.tosi'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue7285' versions = ['Python 3.1', 'Python 2.7', 'Python 3.2'] ```

    f4003412-23b3-41e6-992a-fe93a7a45eb4 commented 15 years ago

    Example codes on multiprocessing module occur errors. I attached the patch to fix these errors.

    http://docs.python.org/dev/py3k/library/multiprocessing.html#module- multiprocessing "16.6.2.10. Listeners and Clients" section

    Fix points are

    1. Listener argument "authkey" must be a byte string
    2. Client argument "authkey" must be a byte string
    3. send_bytes argument must be a byte string

    This is the server code listed on the section. $ cat mpserver.py from multiprocessing.connection import Listener from array import array address = ('localhost', 6000) # family is deduced to be 'AF_INET' listener = Listener(address, authkey='secret password') conn = listener.accept() print('connection accepted from', listener.last_accepted) conn.send([2.25, None, 'junk', float]) conn.send_bytes('hello') conn.send_bytes(array('i', [42, 1729])) conn.close() listener.close()

    And the error is
    $ python3.2 mpserver.py
    Traceback (most recent call last):
      File "mpserver1.py", line 5, in <module>
        listener = Listener(address, authkey='secret password')
      File 
    "/Users/kosmos/local/stow/py3k/lib/python3.2/multiprocessing/connection.
    py", line 100, in __init__
        raise TypeError('authkey should be a byte string')
    TypeError: authkey should be a byte string

    My source code is svn revision 76151. Regards.

    --- Kouki Hashimoto hsmtkk@gmail.com

    sandrotosi commented 14 years ago

    Hello, i've verified that the problem still exists in an up-to-date py3k branch, and that the proposed patch indeed fixes the bug.

    Since the patch no more applies cleanly, I've refreshed it, and also added additional information about authkey that it must be a byte string.

    Regards, Sandro

    orsenthil commented 14 years ago

    Fixed in r85347 and r85348.