test_socket.py: make 2.4 compatible
This commit is contained in:
@@ -890,20 +890,21 @@ class TCPTimeoutTest(SocketTCPTest):
|
|||||||
raise Alarm
|
raise Alarm
|
||||||
old_alarm = signal.signal(signal.SIGALRM, alarm_handler)
|
old_alarm = signal.signal(signal.SIGALRM, alarm_handler)
|
||||||
try:
|
try:
|
||||||
signal.alarm(2) # POSIX allows alarm to be up to 1 second early
|
|
||||||
try:
|
try:
|
||||||
foo = self.serv.accept()
|
signal.alarm(2) # POSIX allows alarm to be up to 1 second early
|
||||||
except socket.timeout:
|
try:
|
||||||
self.fail("caught timeout instead of Alarm")
|
foo = self.serv.accept()
|
||||||
|
except socket.timeout:
|
||||||
|
self.fail("caught timeout instead of Alarm")
|
||||||
|
except Alarm:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
self.fail("caught other exception instead of Alarm")
|
||||||
|
else:
|
||||||
|
self.fail("nothing caught")
|
||||||
|
signal.alarm(0) # shut off alarm
|
||||||
except Alarm:
|
except Alarm:
|
||||||
pass
|
self.fail("got Alarm in wrong place")
|
||||||
except:
|
|
||||||
self.fail("caught other exception instead of Alarm")
|
|
||||||
else:
|
|
||||||
self.fail("nothing caught")
|
|
||||||
signal.alarm(0) # shut off alarm
|
|
||||||
except Alarm:
|
|
||||||
self.fail("got Alarm in wrong place")
|
|
||||||
finally:
|
finally:
|
||||||
# no alarm can be pending. Safe to restore old handler.
|
# no alarm can be pending. Safe to restore old handler.
|
||||||
signal.signal(signal.SIGALRM, old_alarm)
|
signal.signal(signal.SIGALRM, old_alarm)
|
||||||
|
Reference in New Issue
Block a user