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.

classification
Title: lock of multiprocessing.Value is not a keyword-only argument
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: berker.peksag, davin, docs@python, josh.r, martin.panter, sbt
Priority: normal Keywords:

Created on 2015-09-21 04:05 by berker.peksag, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg251196 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-09-21 04:05
From https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Value

    Note that lock is a keyword-only argument.

But the signature of Value (in Lib/multiprocessing/context.py)

    def Value(self, typecode_or_type, *args, lock=True):

and (in Lib/multiprocessing/sharedctypes.py)

    def Value(typecode_or_type, *args, lock=True, ctx=None):

I'd suggest to remove that part of the documentation in 3.4+. We can also make it a keyword-only argument in Python 3.6. That will make the API more similar with https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Array
msg251205 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-09-21 06:00
I’m not familiar with this module, but I believe “lock” is indeed keyword-only. If you were to try a positional argument, it would be picked up as part of *args:

>>> multiprocessing.Value("I")  # Default to 0, lock=True
<Synchronized wrapper for c_uint(0)>
>>> multiprocessing.Value("I", False)  # False == 0, still lock=True
<Synchronized wrapper for c_uint(0)>
>>> multiprocessing.Value("I", lock=False)
c_uint(0)
msg251266 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2015-09-21 21:56
Agreed. Having a named positional varargs argument makes subsequently defined arguments keyword only automatically.
msg251281 - (view) Author: Davin Potts (davin) * (Python committer) Date: 2015-09-22 00:49
Berker: It looks to me like the docs are indeed in sync with the code on Value in that lock really is a keyword-only argument.  It looks like it's been that way since at least 2.7 (I didn't look at earlier).  There are enough other things in the multiprocessing.sharedctypes, maybe it was one of the others that caught your attention instead?

I wished that block/blocking had turned out to be a keyword-only argument in multiprocessing.Lock as part of issue23484, which I immediately thought of when reading this issue.
msg251286 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-09-22 03:32
I didn't test it carefully. It was a mistake on my part :) But I think the function signature could be clearer by changing that part to "*, lock=True".
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69388
2015-09-22 03:32:30berker.peksagsetstatus: open -> closed
resolution: not a bug
messages: + msg251286

stage: needs patch -> resolved
2015-09-22 00:49:33davinsetmessages: + msg251281
2015-09-21 21:56:08josh.rsetnosy: + josh.r
messages: + msg251266
2015-09-21 06:00:06martin.pantersetnosy: + martin.panter
messages: + msg251205
2015-09-21 04:05:21berker.peksagcreate