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
b0516a6b
Commit
b0516a6b
authored
Jan 18, 2009
by
Jesse Noller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge r68708 to py3k, fixes 4449
parent
34f9b4c6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
9 deletions
+33
-9
Doc/library/multiprocessing.rst
Doc/library/multiprocessing.rst
+3
-3
Lib/multiprocessing/sharedctypes.py
Lib/multiprocessing/sharedctypes.py
+10
-4
Lib/test/test_multiprocessing.py
Lib/test/test_multiprocessing.py
+14
-2
Misc/NEWS
Misc/NEWS
+6
-0
No files found.
Doc/library/multiprocessing.rst
View file @
b0516a6b
...
...
@@ -878,7 +878,7 @@ Shared :mod:`ctypes` Objects
It
is
possible
to
create
shared
objects
using
shared
memory
which
can
be
inherited
by
child
processes
.
..
function
::
Value
(
typecode_or_type
[,
*
args
,
lock
]
])
..
function
::
Value
(
typecode_or_type
,
*
args
[,
lock
])
Return
a
:
mod
:`
ctypes
`
object
allocated
from
shared
memory
.
By
default
the
return
value
is
actually
a
synchronized
wrapper
for
the
object
.
...
...
@@ -960,7 +960,7 @@ processes.
*
typecode_or_type
*
determines
the
type
of
the
returned
object
:
it
is
either
a
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
.
module
.
*
\
*
args
*
is
passed
on
to
the
constructor
for
the
type
.
Note
that
setting
and
getting
the
value
is
potentially
non
-
atomic
--
use
:
func
:`
Value
`
instead
to
make
sure
that
access
is
automatically
synchronized
...
...
@@ -970,7 +970,7 @@ processes.
attributes
which
allow
one
to
use
it
to
store
and
retrieve
strings
--
see
documentation
for
:
mod
:`
ctypes
`.
..
function
::
Array
(
typecode_or_type
,
size_or_initializer
[,
*
args
[,
lock
]
])
..
function
::
Array
(
typecode_or_type
,
size_or_initializer
,
*
args
[,
lock
])
The
same
as
:
func
:`
RawArray
`
except
that
depending
on
the
value
of
*
lock
*
a
process
-
safe
synchronization
wrapper
may
be
returned
instead
of
a
raw
ctypes
...
...
Lib/multiprocessing/sharedctypes.py
View file @
b0516a6b
...
...
@@ -66,9 +66,12 @@ def Value(typecode_or_type, *args, lock=None):
Return a synchronization wrapper for a Value
'''
obj
=
RawValue
(
typecode_or_type
,
*
args
)
if
lock
is
None
:
if
lock
is
False
:
return
obj
if
lock
in
(
True
,
None
):
lock
=
RLock
()
assert
hasattr
(
lock
,
'acquire'
)
if
not
hasattr
(
lock
,
'acquire'
):
raise
AttributeError
(
"'%r' has no method 'acquire'"
%
lock
)
return
synchronized
(
obj
,
lock
)
def
Array
(
typecode_or_type
,
size_or_initializer
,
**
kwds
):
...
...
@@ -79,9 +82,12 @@ def Array(typecode_or_type, size_or_initializer, **kwds):
if
kwds
:
raise
ValueError
(
'unrecognized keyword argument(s): %s'
%
list
(
kwds
.
keys
()))
obj
=
RawArray
(
typecode_or_type
,
size_or_initializer
)
if
lock
is
None
:
if
lock
is
False
:
return
obj
if
lock
in
(
True
,
None
):
lock
=
RLock
()
assert
hasattr
(
lock
,
'acquire'
)
if
not
hasattr
(
lock
,
'acquire'
):
raise
AttributeError
(
"'%r' has no method 'acquire'"
%
lock
)
return
synchronized
(
obj
,
lock
)
def
copy
(
obj
):
...
...
Lib/test/test_multiprocessing.py
View file @
b0516a6b
...
...
@@ -830,10 +830,16 @@ class _TestValue(BaseTestCase):
obj3
=
val3
.
get_obj
()
self
.
assertEqual
(
lock
,
lock3
)
arr4
=
self
.
RawValue
(
'i'
,
5
)
arr4
=
self
.
Value
(
'i'
,
5
,
lock
=
False
)
self
.
assertFalse
(
hasattr
(
arr4
,
'get_lock'
))
self
.
assertFalse
(
hasattr
(
arr4
,
'get_obj'
))
self
.
assertRaises
(
AttributeError
,
self
.
Value
,
'i'
,
5
,
lock
=
'navalue'
)
arr5
=
self
.
RawValue
(
'i'
,
5
)
self
.
assertFalse
(
hasattr
(
arr5
,
'get_lock'
))
self
.
assertFalse
(
hasattr
(
arr5
,
'get_obj'
))
class
_TestArray
(
BaseTestCase
):
...
...
@@ -888,9 +894,15 @@ class _TestArray(BaseTestCase):
obj3
=
arr3
.
get_obj
()
self
.
assertEqual
(
lock
,
lock3
)
arr4
=
self
.
RawArray
(
'i'
,
list
(
range
(
10
))
)
arr4
=
self
.
Array
(
'i'
,
range
(
10
),
lock
=
False
)
self
.
assertFalse
(
hasattr
(
arr4
,
'get_lock'
))
self
.
assertFalse
(
hasattr
(
arr4
,
'get_obj'
))
self
.
assertRaises
(
AttributeError
,
self
.
Array
,
'i'
,
range
(
10
),
lock
=
'notalock'
)
arr5
=
self
.
RawArray
(
'i'
,
range
(
10
))
self
.
assertFalse
(
hasattr
(
arr5
,
'get_lock'
))
self
.
assertFalse
(
hasattr
(
arr5
,
'get_obj'
))
#
#
...
...
Misc/NEWS
View file @
b0516a6b
...
...
@@ -135,6 +135,12 @@ Library
- Issue #4959: inspect.formatargspec now works for keyword only arguments
without defaults.
- Issue #4449: AssertionError in mp_benchmarks.py, caused by an underlying issue
in sharedctypes.py.
- Issue #1225107: inspect.isclass() returned True for instances with a custom
__getattr__.
- Issue #3826 and #4791: The socket module now closes the underlying socket
appropriately when it is being used via socket.makefile() objects
rather than delaying the close by waiting for garbage collection to do it.
...
...
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