This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davin
Recipients davin, docs@python, sbt, td
Date 2015-03-01.21:53:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425246785.35.0.513458563058.issue23484@psf.upfronthosting.co.za>
In-reply-to
Content
In the docs for 2.7, multiprocessing.Lock refers to threading.Lock in which the signature for acquire looks like:

    threading.Lock.acquire([blocking])


However, in the current code in 2.7, Modules/_multiprocessing/semaphore.c implements multiprocessing.Lock.acquire to support two arguments:  'block' and 'timeout'.


In the docs for 3.4, threading.Lock.acquire now has both 'blocking' and 'timeout' arguments.  Notably, it specifies: "It is forbidden to specify a timeout when blocking is false."  This is indeed enforced by threading.Lock but not at all by multiprocessing.Lock.  In a 3.4.3 shell:

    >>> import multiprocessing
    >>> import threading
    >>> ml = multiprocessing.Lock()
    >>> ml.acquire(False, 20.0)
    True
    >>> ml.release()
    >>> tl = threading.Lock()
    >>> tl.acquire(False, 20.0)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: can't specify a timeout for a non-blocking call


In 2.7, acquire similarly permits a supplied value for timeout even when set to be non-blocking.

A further difference:  the code in Modules/_multiprocessing/semaphore.c appears to translate a timeout=None into an infinite wait whereas the threading implementation rejects any attempt to supply a None for timeout, demanding a float instead.  (In 3.4, threading uses timeout=-1 to request an infinite wait.)


Given these discrepancies between threading's and multiprocessing's implementations for Lock and given the difficulties in renaming an argument that can be supplied as a non-keyword parameter, the right thing to do at this point is to properly document multiprocessing.Lock's acquire as using 'block' and 'timeout'.
History
Date User Action Args
2015-03-01 21:53:05davinsetrecipients: + davin, docs@python, sbt, td
2015-03-01 21:53:05davinsetmessageid: <1425246785.35.0.513458563058.issue23484@psf.upfronthosting.co.za>
2015-03-01 21:53:05davinlinkissue23484 messages
2015-03-01 21:53:05davincreate