mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
classes: rename NetworkCore.aborted to _aborted
This commit is contained in:
parent
8d15d05711
commit
9ae851e1fc
24
classes.py
24
classes.py
@ -68,7 +68,7 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
|
|||||||
self.encoding = None
|
self.encoding = None
|
||||||
|
|
||||||
self.connected = threading.Event()
|
self.connected = threading.Event()
|
||||||
self.aborted = threading.Event()
|
self._aborted = threading.Event()
|
||||||
self._reply_lock = threading.RLock()
|
self._reply_lock = threading.RLock()
|
||||||
|
|
||||||
# Sets the multiplier for autoconnect delay (grows with time).
|
# Sets the multiplier for autoconnect delay (grows with time).
|
||||||
@ -304,7 +304,7 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
|
|||||||
return self.serverdata.get('netname', self.name)
|
return self.serverdata.get('netname', self.name)
|
||||||
|
|
||||||
def _pre_connect(self):
|
def _pre_connect(self):
|
||||||
self.aborted.clear()
|
self._aborted.clear()
|
||||||
self._init_vars()
|
self._init_vars()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -333,11 +333,11 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
|
|||||||
autoconnect = min(autoconnect, autoconnect_max)
|
autoconnect = min(autoconnect, autoconnect_max)
|
||||||
|
|
||||||
log.info('(%s) _run_autoconnect: Going to auto-reconnect in %s seconds.', self.name, autoconnect)
|
log.info('(%s) _run_autoconnect: Going to auto-reconnect in %s seconds.', self.name, autoconnect)
|
||||||
# Continue when either self.aborted is set or the autoconnect time passes.
|
# Continue when either self._aborted is set or the autoconnect time passes.
|
||||||
# Compared to time.sleep(), this allows us to stop connections quicker if we
|
# Compared to time.sleep(), this allows us to stop connections quicker if we
|
||||||
# break while while for autoconnect.
|
# break while while for autoconnect.
|
||||||
self.aborted.clear()
|
self._aborted.clear()
|
||||||
self.aborted.wait(autoconnect)
|
self._aborted.wait(autoconnect)
|
||||||
|
|
||||||
# Store in the local state what the autoconnect multiplier currently is.
|
# Store in the local state what the autoconnect multiplier currently is.
|
||||||
self.autoconnect_active_multiplier *= autoconnect_multiplier
|
self.autoconnect_active_multiplier *= autoconnect_multiplier
|
||||||
@ -352,7 +352,7 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _pre_disconnect(self):
|
def _pre_disconnect(self):
|
||||||
self.aborted.set()
|
self._aborted.set()
|
||||||
self.was_successful = self.connected.is_set()
|
self.was_successful = self.connected.is_set()
|
||||||
log.debug('(%s) _pre_disconnect: got %s for was_successful state', self.name, self.was_successful)
|
log.debug('(%s) _pre_disconnect: got %s for was_successful state', self.name, self.was_successful)
|
||||||
|
|
||||||
@ -1128,7 +1128,7 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
def _log_connection_error(self, *args, **kwargs):
|
def _log_connection_error(self, *args, **kwargs):
|
||||||
# Log connection errors to ERROR unless were shutting down (in which case,
|
# Log connection errors to ERROR unless were shutting down (in which case,
|
||||||
# the given text goes to DEBUG).
|
# the given text goes to DEBUG).
|
||||||
if self.aborted.is_set() or control.tried_shutdown:
|
if self._aborted.is_set() or control.tried_shutdown:
|
||||||
log.debug(*args, **kwargs)
|
log.debug(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
log.error(*args, **kwargs)
|
log.error(*args, **kwargs)
|
||||||
@ -1342,14 +1342,14 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
"""Main IRC loop which listens for messages."""
|
"""Main IRC loop which listens for messages."""
|
||||||
buf = b""
|
buf = b""
|
||||||
data = b""
|
data = b""
|
||||||
while not self.aborted.is_set():
|
while not self._aborted.is_set():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = self._socket.recv(2048)
|
data = self._socket.recv(2048)
|
||||||
except OSError:
|
except OSError:
|
||||||
# Suppress socket read warnings from lingering recv() calls if
|
# Suppress socket read warnings from lingering recv() calls if
|
||||||
# we've been told to shutdown.
|
# we've been told to shutdown.
|
||||||
if self.aborted.is_set():
|
if self._aborted.is_set():
|
||||||
return
|
return
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -1386,8 +1386,8 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
|
|
||||||
def send(self, data, queue=True):
|
def send(self, data, queue=True):
|
||||||
"""send() wrapper with optional queueing support."""
|
"""send() wrapper with optional queueing support."""
|
||||||
if self.aborted.is_set():
|
if self._aborted.is_set():
|
||||||
log.debug('(%s) refusing to queue data %r as self.aborted is set', self.name, data)
|
log.debug('(%s) refusing to queue data %r as self._aborted is set', self.name, data)
|
||||||
return
|
return
|
||||||
if queue:
|
if queue:
|
||||||
# XXX: we don't really know how to handle blocking queues yet, so
|
# XXX: we don't really know how to handle blocking queues yet, so
|
||||||
@ -1400,7 +1400,7 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
"""Loop to process outgoing queue data."""
|
"""Loop to process outgoing queue data."""
|
||||||
while True:
|
while True:
|
||||||
throttle_time = self.serverdata.get('throttle_time', 0.005)
|
throttle_time = self.serverdata.get('throttle_time', 0.005)
|
||||||
if not self.aborted.wait(throttle_time):
|
if not self._aborted.wait(throttle_time):
|
||||||
data = self._queue.get()
|
data = self._queue.get()
|
||||||
if data is None:
|
if data is None:
|
||||||
log.debug('(%s) Stopping queue thread due to getting None as item', self.name)
|
log.debug('(%s) Stopping queue thread due to getting None as item', self.name)
|
||||||
|
@ -361,7 +361,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
def endburstf():
|
def endburstf():
|
||||||
# Delay ENDBURST by X seconds if requested.
|
# Delay ENDBURST by X seconds if requested.
|
||||||
if self.aborted.wait(endburst_delay):
|
if self._aborted.wait(endburst_delay):
|
||||||
# We managed to catch the abort flag before sending ENDBURST, so break
|
# We managed to catch the abort flag before sending ENDBURST, so break
|
||||||
log.debug('(%s) stopping endburstf() for %s as aborted was set', self.name, sid)
|
log.debug('(%s) stopping endburstf() for %s as aborted was set', self.name, sid)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user