File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2616,9 +2616,18 @@ def testSendmsgTimeout(self):
26162616 def _testSendmsgTimeout (self ):
26172617 try :
26182618 self .cli_sock .settimeout (0.03 )
2619- with self . assertRaises ( socket . timeout ) :
2619+ try :
26202620 while True :
26212621 self .sendmsgToServer ([b"a" * 512 ])
2622+ except socket .timeout :
2623+ pass
2624+ except OSError as exc :
2625+ if exc .errno != errno .ENOMEM :
2626+ raise
2627+ # bpo-33937 the test randomly fails on Travis CI with
2628+ # "OSError: [Errno 12] Cannot allocate memory"
2629+ else :
2630+ self .fail ("socket.timeout not raised" )
26222631 finally :
26232632 self .misc_event .set ()
26242633
@@ -2641,8 +2650,10 @@ def _testSendmsgDontWait(self):
26412650 with self .assertRaises (OSError ) as cm :
26422651 while True :
26432652 self .sendmsgToServer ([b"a" * 512 ], [], socket .MSG_DONTWAIT )
2653+ # bpo-33937: catch also ENOMEM, the test randomly fails on Travis CI
2654+ # with "OSError: [Errno 12] Cannot allocate memory"
26442655 self .assertIn (cm .exception .errno ,
2645- (errno .EAGAIN , errno .EWOULDBLOCK ))
2656+ (errno .EAGAIN , errno .EWOULDBLOCK , errno . ENOMEM ))
26462657 finally :
26472658 self .misc_event .set ()
26482659
You can’t perform that action at this time.
0 commit comments