File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2287,9 +2287,18 @@ def testSendmsgTimeout(self):
2287
2287
def _testSendmsgTimeout (self ):
2288
2288
try :
2289
2289
self .cli_sock .settimeout (0.03 )
2290
- with self . assertRaises ( socket . timeout ) :
2290
+ try :
2291
2291
while True :
2292
2292
self .sendmsgToServer ([b"a" * 512 ])
2293
+ except socket .timeout :
2294
+ pass
2295
+ except OSError as exc :
2296
+ if exc .errno != errno .ENOMEM :
2297
+ raise
2298
+ # bpo-33937 the test randomly fails on Travis CI with
2299
+ # "OSError: [Errno 12] Cannot allocate memory"
2300
+ else :
2301
+ self .fail ("socket.timeout not raised" )
2293
2302
finally :
2294
2303
self .misc_event .set ()
2295
2304
@@ -2312,8 +2321,10 @@ def _testSendmsgDontWait(self):
2312
2321
with self .assertRaises (OSError ) as cm :
2313
2322
while True :
2314
2323
self .sendmsgToServer ([b"a" * 512 ], [], socket .MSG_DONTWAIT )
2324
+ # bpo-33937: catch also ENOMEM, the test randomly fails on Travis CI
2325
+ # with "OSError: [Errno 12] Cannot allocate memory"
2315
2326
self .assertIn (cm .exception .errno ,
2316
- (errno .EAGAIN , errno .EWOULDBLOCK ))
2327
+ (errno .EAGAIN , errno .EWOULDBLOCK , errno . ENOMEM ))
2317
2328
finally :
2318
2329
self .misc_event .set ()
2319
2330
You can’t perform that action at this time.
0 commit comments