File tree 1 file changed +13
-2
lines changed 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2616,9 +2616,18 @@ def testSendmsgTimeout(self):
2616
2616
def _testSendmsgTimeout (self ):
2617
2617
try :
2618
2618
self .cli_sock .settimeout (0.03 )
2619
- with self . assertRaises ( socket . timeout ) :
2619
+ try :
2620
2620
while True :
2621
2621
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" )
2622
2631
finally :
2623
2632
self .misc_event .set ()
2624
2633
@@ -2641,8 +2650,10 @@ def _testSendmsgDontWait(self):
2641
2650
with self .assertRaises (OSError ) as cm :
2642
2651
while True :
2643
2652
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"
2644
2655
self .assertIn (cm .exception .errno ,
2645
- (errno .EAGAIN , errno .EWOULDBLOCK ))
2656
+ (errno .EAGAIN , errno .EWOULDBLOCK , errno . ENOMEM ))
2646
2657
finally :
2647
2658
self .misc_event .set ()
2648
2659
You can’t perform that action at this time.
0 commit comments