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
1743db5c
Commit
1743db5c
authored
Dec 20, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
08316769
29b15d11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
Lib/test/test_mailbox.py
Lib/test/test_mailbox.py
+8
-11
No files found.
Lib/test/test_mailbox.py
View file @
1743db5c
...
@@ -17,10 +17,6 @@ try:
...
@@ -17,10 +17,6 @@ try:
import
fcntl
import
fcntl
except
ImportError
:
except
ImportError
:
pass
pass
try
:
import
multiprocessing
except
ImportError
:
multiprocessing
=
None
class
TestBase
(
unittest
.
TestCase
):
class
TestBase
(
unittest
.
TestCase
):
...
@@ -998,12 +994,13 @@ class _TestMboxMMDF(TestMailbox):
...
@@ -998,12 +994,13 @@ class _TestMboxMMDF(TestMailbox):
self
.
_box
=
self
.
_factory
(
self
.
_path
)
self
.
_box
=
self
.
_factory
(
self
.
_path
)
@
unittest
.
skipUnless
(
hasattr
(
os
,
'fork'
),
"Test needs fork()."
)
@
unittest
.
skipUnless
(
hasattr
(
os
,
'fork'
),
"Test needs fork()."
)
@
unittest
.
skipUnless
(
multiprocessing
,
"Test needs multiprocessing
."
)
@
unittest
.
skipUnless
(
hasattr
(
socket
,
'socketpair'
),
"Test needs socketpair()
."
)
def
test_lock_conflict
(
self
):
def
test_lock_conflict
(
self
):
# Fork off a child process that will lock the mailbox temporarily,
# Fork off a child process that will lock the mailbox temporarily,
# unlock it and exit.
# unlock it and exit.
ready
=
multiprocessing
.
Event
()
c
,
p
=
socket
.
socketpair
()
done
=
multiprocessing
.
Event
()
self
.
addCleanup
(
c
.
close
)
self
.
addCleanup
(
p
.
close
)
pid
=
os
.
fork
()
pid
=
os
.
fork
()
if
pid
==
0
:
if
pid
==
0
:
...
@@ -1011,22 +1008,22 @@ class _TestMboxMMDF(TestMailbox):
...
@@ -1011,22 +1008,22 @@ class _TestMboxMMDF(TestMailbox):
try
:
try
:
# lock the mailbox, and signal the parent it can proceed
# lock the mailbox, and signal the parent it can proceed
self
.
_box
.
lock
()
self
.
_box
.
lock
()
ready
.
set
(
)
c
.
send
(
b'c'
)
# wait until the parent is done, and unlock the mailbox
# wait until the parent is done, and unlock the mailbox
done
.
wait
(
5
)
c
.
recv
(
1
)
self
.
_box
.
unlock
()
self
.
_box
.
unlock
()
finally
:
finally
:
os
.
_exit
(
0
)
os
.
_exit
(
0
)
# In the parent, wait until the child signals it locked the mailbox.
# In the parent, wait until the child signals it locked the mailbox.
ready
.
wait
(
5
)
p
.
recv
(
1
)
try
:
try
:
self
.
assertRaises
(
mailbox
.
ExternalClashError
,
self
.
assertRaises
(
mailbox
.
ExternalClashError
,
self
.
_box
.
lock
)
self
.
_box
.
lock
)
finally
:
finally
:
# Signal the child it can now release the lock and exit.
# Signal the child it can now release the lock and exit.
done
.
set
(
)
p
.
send
(
b'p'
)
# Wait for child to exit. Locking should now succeed.
# Wait for child to exit. Locking should now succeed.
exited_pid
,
status
=
os
.
waitpid
(
pid
,
0
)
exited_pid
,
status
=
os
.
waitpid
(
pid
,
0
)
...
...
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