[docs] [issue35786] get_lock() method is not present for Values created using multiprocessing.Manager()

Lorenzo Persichetti report at bugs.python.org
Sat Jan 19 16:50:36 EST 2019


New submission from Lorenzo Persichetti <lpersichetti at gmail.com>:

According to the documentation of the multiprocessing.Value() class available here https://docs.python.org/3.6/library/multiprocessing.html#multiprocessing.Value

Operations like += which involve a read and write are not atomic. So if, for instance, you want to atomically increment a shared value it is insufficient to just do

counter.value += 1
Assuming the associated lock is recursive (which it is by default) you can instead do

with counter.get_lock():
    counter.value += 1

What happens is that when running the following snippet

import multiprocessing
manager = multiprocessing.Manager()
value = manager.Value('i', 0)
value.get_lock()

the result is 
AttributeError: 'ValueProxy' object has no attribute 'get_lock'

----------
assignee: docs at python
components: Documentation, Library (Lib), Windows
messages: 334070
nosy: Lorenzo Persichetti, docs at python, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: get_lock() method is not present for Values created using multiprocessing.Manager()
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35786>
_______________________________________


More information about the docs mailing list