mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-33937: Catch ENOMEM error in test_socket (#9557)
Fix test_socket.SendmsgSCTPStreamTest: catch ENOMEM error. testSendmsgTimeout() and testSendmsgDontWait() randomly fail on Travis CI with: "OSError: [Errno 12] Cannot allocate memory".
This commit is contained in:
parent
6ea29c5e90
commit
46f40be8b9
1 changed files with 13 additions and 2 deletions
|
@ -2616,9 +2616,18 @@ class SendmsgStreamTests(SendmsgTests):
|
|||
def _testSendmsgTimeout(self):
|
||||
try:
|
||||
self.cli_sock.settimeout(0.03)
|
||||
with self.assertRaises(socket.timeout):
|
||||
try:
|
||||
while True:
|
||||
self.sendmsgToServer([b"a"*512])
|
||||
except socket.timeout:
|
||||
pass
|
||||
except OSError as exc:
|
||||
if exc.errno != errno.ENOMEM:
|
||||
raise
|
||||
# bpo-33937 the test randomly fails on Travis CI with
|
||||
# "OSError: [Errno 12] Cannot allocate memory"
|
||||
else:
|
||||
self.fail("socket.timeout not raised")
|
||||
finally:
|
||||
self.misc_event.set()
|
||||
|
||||
|
@ -2641,8 +2650,10 @@ class SendmsgStreamTests(SendmsgTests):
|
|||
with self.assertRaises(OSError) as cm:
|
||||
while True:
|
||||
self.sendmsgToServer([b"a"*512], [], socket.MSG_DONTWAIT)
|
||||
# bpo-33937: catch also ENOMEM, the test randomly fails on Travis CI
|
||||
# with "OSError: [Errno 12] Cannot allocate memory"
|
||||
self.assertIn(cm.exception.errno,
|
||||
(errno.EAGAIN, errno.EWOULDBLOCK))
|
||||
(errno.EAGAIN, errno.EWOULDBLOCK, errno.ENOMEM))
|
||||
finally:
|
||||
self.misc_event.set()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue