Message334070
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' |
|
Date |
User |
Action |
Args |
2019-01-19 21:50:36 | Lorenzo Persichetti | set | recipients:
+ Lorenzo Persichetti, paul.moore, tim.golden, docs@python, zach.ware, steve.dower |
2019-01-19 21:50:32 | Lorenzo Persichetti | set | messageid: <1547934632.93.0.223661167179.issue35786@roundup.psfhosted.org> |
2019-01-19 21:50:32 | Lorenzo Persichetti | link | issue35786 messages |
2019-01-19 21:50:32 | Lorenzo Persichetti | create | |
|