Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
66aa99df
Commit
66aa99df
authored
Nov 17, 2013
by
Richard Oudkerk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 16998: Clarify that += on a shared value is not atomic.
parent
0f319cfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
Doc/library/multiprocessing.rst
Doc/library/multiprocessing.rst
+18
-6
No files found.
Doc/library/multiprocessing.rst
View file @
66aa99df
...
...
@@ -1006,12 +1006,24 @@ inherited by child processes.
ctypes type or a one character typecode of the kind used by the :mod:`array`
module. *\*args* is passed on to the constructor for the type.
If *lock* is ``True`` (the default) then a new lock object is created to
synchronize access to the value. If *lock* is a :class:`Lock` or
:class:`RLock` object then that will be used to synchronize access to the
value. If *lock* is ``False`` then access to the returned object will not be
automatically protected by a lock, so it will not necessarily be
"process-safe".
If *lock* is ``True`` (the default) then a new recursive lock
object is created to synchronize access to the value. If *lock* is
a :class:`Lock` or :class:`RLock` object then that will be used to
synchronize access to the value. If *lock* is ``False`` then
access to the returned object will not be automatically protected
by a lock, so it will not necessarily be "process-safe".
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
Note that *lock* is a keyword-only argument.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment