mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-02 05:24:51 +00:00
Add timeout when connecting
This commit is contained in:
parent
0a6583a43c
commit
52354b93d0
1 changed files with 3 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class Connection:
|
||||
TIMEOUT = 10
|
||||
MAX_RETRIES = 3
|
||||
|
||||
MODES = {
|
||||
|
|
@ -49,8 +50,8 @@ class Connection:
|
|||
|
||||
try:
|
||||
log.info("Connecting...")
|
||||
await self.protocol.connect(self.address)
|
||||
except OSError:
|
||||
await asyncio.wait_for(self.protocol.connect(self.address), Connection.TIMEOUT)
|
||||
except (OSError, asyncio.TimeoutError):
|
||||
self.protocol.close()
|
||||
await asyncio.sleep(1)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue