mirror of https://github.com/Shizmob/pydle.git
Added pydle.Client.READ_TIMEOUT proxy & warnings
- should work as expected, and emit a warning to users resolves #126
This commit is contained in:
parent
bfaa01ce96
commit
d82159d530
|
@ -5,6 +5,7 @@ import logging
|
||||||
from asyncio import new_event_loop, gather, get_event_loop, sleep
|
from asyncio import new_event_loop, gather, get_event_loop, sleep
|
||||||
|
|
||||||
from . import connection, protocol
|
from . import connection, protocol
|
||||||
|
import warnings
|
||||||
|
|
||||||
__all__ = ['Error', 'AlreadyInChannel', 'NotInChannel', 'BasicClient', 'ClientPool']
|
__all__ = ['Error', 'AlreadyInChannel', 'NotInChannel', 'BasicClient', 'ClientPool']
|
||||||
DEFAULT_NICKNAME = '<unregistered>'
|
DEFAULT_NICKNAME = '<unregistered>'
|
||||||
|
@ -38,6 +39,23 @@ class BasicClient:
|
||||||
RECONNECT_DELAYED = True
|
RECONNECT_DELAYED = True
|
||||||
RECONNECT_DELAYS = [5, 5, 10, 30, 120, 600]
|
RECONNECT_DELAYS = [5, 5, 10, 30, 120, 600]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def PING_TIMEOUT(self):
|
||||||
|
warnings.warn(
|
||||||
|
"PING_TIMEOUT has been moved to READ_TIMEOUT and may be removed in a future version. "
|
||||||
|
"Please migrate to READ_TIMEOUT.",
|
||||||
|
DeprecationWarning
|
||||||
|
)
|
||||||
|
return self.READ_TIMEOUT
|
||||||
|
|
||||||
|
@PING_TIMEOUT.setter
|
||||||
|
def PING_TIMEOUT(self, value):
|
||||||
|
warnings.warn(
|
||||||
|
"PING_TIMEOUT has been moved to READ_TIMEOUT and may be removed in a future version",
|
||||||
|
DeprecationWarning
|
||||||
|
)
|
||||||
|
self.READ_TIMEOUT = value
|
||||||
|
|
||||||
def __init__(self, nickname, fallback_nicknames=[], username=None, realname=None,
|
def __init__(self, nickname, fallback_nicknames=[], username=None, realname=None,
|
||||||
eventloop=None, **kwargs):
|
eventloop=None, **kwargs):
|
||||||
""" Create a client. """
|
""" Create a client. """
|
||||||
|
@ -348,7 +366,8 @@ class BasicClient:
|
||||||
try:
|
try:
|
||||||
data = await self.connection.recv(timeout=self.READ_TIMEOUT)
|
data = await self.connection.recv(timeout=self.READ_TIMEOUT)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self.logger.warning('>> Receive timeout reached, sending ping to check connection state...')
|
self.logger.warning(
|
||||||
|
'>> Receive timeout reached, sending ping to check connection state...')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.rawmsg("PING", self.server_tag)
|
await self.rawmsg("PING", self.server_tag)
|
||||||
|
@ -372,7 +391,6 @@ class BasicClient:
|
||||||
message = self._parse_message()
|
message = self._parse_message()
|
||||||
self.eventloop.create_task(self.on_raw(message))
|
self.eventloop.create_task(self.on_raw(message))
|
||||||
|
|
||||||
|
|
||||||
async def on_data_error(self, exception):
|
async def on_data_error(self, exception):
|
||||||
""" Handle error. """
|
""" Handle error. """
|
||||||
self.logger.error('Encountered error on socket.',
|
self.logger.error('Encountered error on socket.',
|
||||||
|
|
Loading…
Reference in New Issue