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
f74dee4b
Commit
f74dee4b
authored
Mar 13, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit for #11233
parents
279755a1
d3cccd2a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
Lib/test/test_threadsignals.py
Lib/test/test_threadsignals.py
+17
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_threadsignals.py
View file @
f74dee4b
...
@@ -73,18 +73,29 @@ class ThreadSignals(unittest.TestCase):
...
@@ -73,18 +73,29 @@ class ThreadSignals(unittest.TestCase):
def
test_lock_acquire_interruption
(
self
):
def
test_lock_acquire_interruption
(
self
):
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# in a deadlock.
# in a deadlock.
# XXX this test can fail when the legacy (non-semaphore) implementation
# of locks is used in thread_pthread.h, see issue #11223.
oldalrm
=
signal
.
signal
(
signal
.
SIGALRM
,
self
.
alarm_interrupt
)
oldalrm
=
signal
.
signal
(
signal
.
SIGALRM
,
self
.
alarm_interrupt
)
try
:
try
:
lock
=
thread
.
allocate_lock
()
lock
=
thread
.
allocate_lock
()
lock
.
acquire
()
lock
.
acquire
()
signal
.
alarm
(
1
)
signal
.
alarm
(
1
)
self
.
assertRaises
(
KeyboardInterrupt
,
lock
.
acquire
)
t1
=
time
.
time
()
self
.
assertRaises
(
KeyboardInterrupt
,
lock
.
acquire
,
timeout
=
5
)
dt
=
time
.
time
()
-
t1
# Checking that KeyboardInterrupt was raised is not sufficient.
# We want to assert that lock.acquire() was interrupted because
# of the signal, not that the signal handler was called immediately
# after timeout return of lock.acquire() (which can fool assertRaises).
self
.
assertLess
(
dt
,
3.0
)
finally
:
finally
:
signal
.
signal
(
signal
.
SIGALRM
,
oldalrm
)
signal
.
signal
(
signal
.
SIGALRM
,
oldalrm
)
def
test_rlock_acquire_interruption
(
self
):
def
test_rlock_acquire_interruption
(
self
):
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
# in a deadlock.
# in a deadlock.
# XXX this test can fail when the legacy (non-semaphore) implementation
# of locks is used in thread_pthread.h, see issue #11223.
oldalrm
=
signal
.
signal
(
signal
.
SIGALRM
,
self
.
alarm_interrupt
)
oldalrm
=
signal
.
signal
(
signal
.
SIGALRM
,
self
.
alarm_interrupt
)
try
:
try
:
rlock
=
thread
.
RLock
()
rlock
=
thread
.
RLock
()
...
@@ -98,7 +109,11 @@ class ThreadSignals(unittest.TestCase):
...
@@ -98,7 +109,11 @@ class ThreadSignals(unittest.TestCase):
rlock
.
release
()
rlock
.
release
()
time
.
sleep
(
0.01
)
time
.
sleep
(
0.01
)
signal
.
alarm
(
1
)
signal
.
alarm
(
1
)
self
.
assertRaises
(
KeyboardInterrupt
,
rlock
.
acquire
)
t1
=
time
.
time
()
self
.
assertRaises
(
KeyboardInterrupt
,
rlock
.
acquire
,
timeout
=
5
)
dt
=
time
.
time
()
-
t1
# See rationale above in test_lock_acquire_interruption
self
.
assertLess
(
dt
,
3.0
)
finally
:
finally
:
signal
.
signal
(
signal
.
SIGALRM
,
oldalrm
)
signal
.
signal
(
signal
.
SIGALRM
,
oldalrm
)
...
...
Misc/NEWS
View file @
f74dee4b
...
@@ -188,6 +188,9 @@ Tools/Demos
...
@@ -188,6 +188,9 @@ Tools/Demos
Tests
Tests
-----
-----
-
Issue
#
11223
:
Fix
test_threadsignals
to
fail
,
not
hang
,
when
the
non
-
semaphore
implementation
of
locks
is
used
under
POSIX
.
-
Issue
#
10911
:
Add
tests
on
CGI
with
non
-
ASCII
characters
.
Patch
written
by
-
Issue
#
10911
:
Add
tests
on
CGI
with
non
-
ASCII
characters
.
Patch
written
by
Pierre
Quentel
.
Pierre
Quentel
.
...
...
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