Skip to content

Commit 17842eb

Browse files
committed
alive check fix
1 parent 4d1dbb9 commit 17842eb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pproxy/server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ async def check_server_alive(interval, rserver, verbose):
171171
if remote.direct:
172172
continue
173173
try:
174-
_, writer = await remote.open_connection(None, None, None, None)
174+
_, writer = await remote.open_connection(None, None, None, None, timeout=3)
175+
except asyncio.CancelledError as ex:
176+
return
175177
except Exception as ex:
176178
if remote.alive:
177179
verbose(f'{remote.rproto.name} {remote.bind} -> OFFLINE')
@@ -315,7 +317,7 @@ def connection_made(prot, transport):
315317
def datagram_received(prot, data, addr):
316318
asyncio.ensure_future(datagram_handler(prot.transport, data, addr, **vars(self), **args))
317319
return asyncio.get_event_loop().create_datagram_endpoint(Protocol, local_addr=(self.host_name, self.port))
318-
async def open_connection(self, host, port, local_addr, lbind):
320+
async def open_connection(self, host, port, local_addr, lbind, timeout=SOCKET_TIMEOUT):
319321
if self.reuse or self.ssh:
320322
if self.streams is None or self.streams.done() and (self.reuse and not self.handler):
321323
self.streams = asyncio.get_event_loop().create_future()
@@ -354,7 +356,7 @@ async def open_connection(self, host, port, local_addr, lbind):
354356
wait = asyncio.open_unix_connection(path=self.bind, ssl=self.sslclient, server_hostname='' if self.sslclient else None)
355357
else:
356358
wait = asyncio.open_connection(host=self.host_name, port=self.port, ssl=self.sslclient, local_addr=local_addr, family=family)
357-
reader, writer = await asyncio.wait_for(wait, timeout=SOCKET_TIMEOUT)
359+
reader, writer = await asyncio.wait_for(wait, timeout=timeout)
358360
except Exception as ex:
359361
if self.reuse:
360362
self.streams.set_exception(ex)

0 commit comments

Comments
 (0)