3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

classes: mark reply_lock, init_vars as private

This commit is contained in:
James Lu 2017-07-14 05:22:05 -07:00
parent fa4d831e44
commit 716ffd389b
2 changed files with 10 additions and 10 deletions

View File

@ -69,14 +69,14 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
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).
self.autoconnect_active_multiplier = 1 self.autoconnect_active_multiplier = 1
self.was_successful = False self.was_successful = False
self.init_vars() self._init_vars()
def log_setup(self): def log_setup(self):
""" """
@ -103,7 +103,7 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
self.loghandlers.append(handler) self.loghandlers.append(handler)
log.addHandler(handler) log.addHandler(handler)
def init_vars(self): def _init_vars(self):
""" """
(Re)sets an IRC object to its default state. This should be called when (Re)sets an IRC object to its default state. This should be called when
an IRC object is first created, and on every reconnection to a network. an IRC object is first created, and on every reconnection to a network.
@ -270,7 +270,7 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
This function wraps around _reply() and can be monkey-patched in a thread-safe manner This function wraps around _reply() and can be monkey-patched in a thread-safe manner
to temporarily redirect plugin output to another target. to temporarily redirect plugin output to another target.
""" """
with self.reply_lock: with self._reply_lock:
self._reply(*args, **kwargs) self._reply(*args, **kwargs)
def error(self, text, **kwargs): def error(self, text, **kwargs):
@ -323,7 +323,7 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
def _pre_connect(self): def _pre_connect(self):
self.aborted.clear() self.aborted.clear()
self.init_vars() self._init_vars()
try: try:
self.validate_server_conf() self.validate_server_conf()
@ -386,8 +386,8 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
# Internal hook signifying that a network has disconnected. # Internal hook signifying that a network has disconnected.
self.call_hooks([None, 'PYLINK_DISCONNECT', {'was_successful': self.was_successful}]) self.call_hooks([None, 'PYLINK_DISCONNECT', {'was_successful': self.was_successful}])
log.debug('(%s) _post_disconnect: Clearing state via init_vars().', self.name) log.debug('(%s) _post_disconnect: Clearing state via _init_vars().', self.name)
self.init_vars() self._init_vars()
def validate_server_conf(self): def validate_server_conf(self):
return return
@ -1108,8 +1108,8 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
self._ping_timer = None self._ping_timer = None
self._socket = None self._socket = None
def init_vars(self, *args, **kwargs): def _init_vars(self, *args, **kwargs):
super().init_vars(*args, **kwargs) super()._init_vars(*args, **kwargs)
# Set IRC specific variables for ping checking and queuing # Set IRC specific variables for ping checking and queuing
self.lastping = time.time() self.lastping = time.time()

View File

@ -127,7 +127,7 @@ def remote(irc, source, args):
old_reply = remoteirc._reply old_reply = remoteirc._reply
with remoteirc.reply_lock: with remoteirc._reply_lock:
try: # Remotely call the command (use the PyLink client as a dummy user). try: # Remotely call the command (use the PyLink client as a dummy user).
# Override the remote irc.reply() to send replies HERE. # Override the remote irc.reply() to send replies HERE.
log.debug('(%s) networks.remote: overriding reply() of IRC object %s', irc.name, netname) log.debug('(%s) networks.remote: overriding reply() of IRC object %s', irc.name, netname)