File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 42
42
run : hatch run cov:test --cov-fail-under 75 || hatch run test:test --lf
43
43
- name : Run the tests on pypy
44
44
if : ${{ startsWith(matrix.python-version, 'pypy') }}
45
- run : hatch run test:test || hatch run test:test --lf
45
+ run : hatch run test:nowarn || hatch run test:nowarn --lf
46
46
- name : Run the tests on windows
47
47
if : ${{ startsWith(matrix.os, 'windows') }}
48
48
run : hatch run cov:nowarn -s || hatch run cov:nowarn --lf
Original file line number Diff line number Diff line change @@ -2337,6 +2337,8 @@ def init_httpserver(self):
2337
2337
)
2338
2338
2339
2339
# binding sockets must be called from inside an event loop
2340
+ if not self .sock :
2341
+ self ._find_http_port ()
2340
2342
self .io_loop .add_callback (self ._bind_http_server )
2341
2343
2342
2344
def _bind_http_server (self ):
@@ -2371,10 +2373,16 @@ def _bind_http_server_unix(self):
2371
2373
return True
2372
2374
2373
2375
def _bind_http_server_tcp (self ):
2376
+ self .http_server .listen (self .port , self .ip )
2377
+ return True
2378
+
2379
+ def _find_http_port (self ):
2374
2380
success = None
2375
2381
for port in random_ports (self .port , self .port_retries + 1 ):
2382
+ tmp_sock = socket .socket ()
2376
2383
try :
2377
- self .http_server .listen (port , self .ip )
2384
+ tmp_sock .setsockopt (socket .SOL_SOCKET , socket .SO_LINGER , b"\0 " * 8 )
2385
+ tmp_sock .bind ((self .ip , port ))
2378
2386
except OSError as e :
2379
2387
if e .errno == errno .EADDRINUSE :
2380
2388
if self .port_retries :
@@ -2396,6 +2404,8 @@ def _bind_http_server_tcp(self):
2396
2404
self .port = port
2397
2405
success = True
2398
2406
break
2407
+ finally :
2408
+ tmp_sock .close ()
2399
2409
if not success :
2400
2410
if self .port_retries :
2401
2411
self .log .critical (
@@ -2413,7 +2423,6 @@ def _bind_http_server_tcp(self):
2413
2423
% port
2414
2424
)
2415
2425
self .exit (1 )
2416
- return success
2417
2426
2418
2427
@staticmethod
2419
2428
def _init_asyncio_patch ():
You can’t perform that action at this time.
0 commit comments