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
02cb0eb2
Commit
02cb0eb2
authored
Apr 01, 2009
by
Jesse Noller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix multiprocessing.event to match the new threading.Event API
parent
a83da350
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
Doc/library/multiprocessing.rst
Doc/library/multiprocessing.rst
+6
-0
Lib/multiprocessing/synchronize.py
Lib/multiprocessing/synchronize.py
+5
-0
Lib/test/test_multiprocessing.py
Lib/test/test_multiprocessing.py
+9
-7
No files found.
Doc/library/multiprocessing.rst
View file @
02cb0eb2
...
...
@@ -836,6 +836,12 @@ object -- see :ref:`multiprocessing-managers`.
..
class
::
Event
()
A
clone
of
:
class
:`
threading
.
Event
`.
This
method
returns
the
state
of
the
internal
semaphore
on
exit
,
so
it
will
always
return
``
True
``
except
if
a
timeout
is
given
and
the
operation
times
out
.
..
versionchanged
::
2.7
Previously
,
the
method
always
returned
``
None
``.
..
class
::
Lock
()
...
...
Lib/multiprocessing/synchronize.py
View file @
02cb0eb2
...
...
@@ -301,5 +301,10 @@ class Event(object):
self
.
_flag
.
release
()
else
:
self
.
_cond
.
wait
(
timeout
)
if
self
.
_flag
.
acquire
(
False
):
self
.
_flag
.
release
()
return
True
return
False
finally
:
self
.
_cond
.
release
()
Lib/test/test_multiprocessing.py
View file @
02cb0eb2
...
...
@@ -749,20 +749,22 @@ class _TestEvent(BaseTestCase):
# Removed temporaily, due to API shear, this does not
# work with threading._Event objects. is_set == isSet
#
self.assertEqual(event.is_set(), False)
self
.
assertEqual
(
event
.
is_set
(),
False
)
self
.
assertEqual
(
wait
(
0.0
),
None
)
# Removed, threading.Event.wait() will return the value of the __flag
# instead of None. API Shear with the semaphore backed mp.Event
self
.
assertEqual
(
wait
(
0.0
),
False
)
self
.
assertTimingAlmostEqual
(
wait
.
elapsed
,
0.0
)
self
.
assertEqual
(
wait
(
TIMEOUT1
),
Non
e
)
self
.
assertEqual
(
wait
(
TIMEOUT1
),
Fals
e
)
self
.
assertTimingAlmostEqual
(
wait
.
elapsed
,
TIMEOUT1
)
event
.
set
()
# See note above on the API differences
#
self.assertEqual(event.is_set(), True)
self
.
assertEqual
(
wait
(),
Non
e
)
self
.
assertEqual
(
event
.
is_set
(),
True
)
self
.
assertEqual
(
wait
(),
Tru
e
)
self
.
assertTimingAlmostEqual
(
wait
.
elapsed
,
0.0
)
self
.
assertEqual
(
wait
(
TIMEOUT1
),
Non
e
)
self
.
assertEqual
(
wait
(
TIMEOUT1
),
Tru
e
)
self
.
assertTimingAlmostEqual
(
wait
.
elapsed
,
0.0
)
# self.assertEqual(event.is_set(), True)
...
...
@@ -771,7 +773,7 @@ class _TestEvent(BaseTestCase):
#self.assertEqual(event.is_set(), False)
self
.
Process
(
target
=
self
.
_test_event
,
args
=
(
event
,)).
start
()
self
.
assertEqual
(
wait
(),
Non
e
)
self
.
assertEqual
(
wait
(),
Tru
e
)
#
#
...
...
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