mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
Move ts_lock definition into PyLinkNetworkCoreWithUtils
This commit is contained in:
parent
928dbf80bb
commit
ad2d5a5ae0
12
classes.py
12
classes.py
@ -59,9 +59,6 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
|
|||||||
self.casemapping = 'rfc1459'
|
self.casemapping = 'rfc1459'
|
||||||
self.hook_map = {}
|
self.hook_map = {}
|
||||||
|
|
||||||
# Lock for updateTS to make sure only one thread can change the channel TS at one time.
|
|
||||||
self.ts_lock = threading.Lock()
|
|
||||||
|
|
||||||
# Lists required conf keys for the server block.
|
# Lists required conf keys for the server block.
|
||||||
self.conf_keys = {'ip', 'port', 'hostname', 'sid', 'sidrange', 'protocol', 'sendpass',
|
self.conf_keys = {'ip', 'port', 'hostname', 'sid', 'sidrange', 'protocol', 'sendpass',
|
||||||
'recvpass'}
|
'recvpass'}
|
||||||
@ -425,6 +422,11 @@ class PyLinkNetworkCore(utils.DeprecatedAttributesObject, utils.CamelCaseToSnake
|
|||||||
|
|
||||||
|
|
||||||
class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
|
class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
# Lock for updateTS to make sure only one thread can change the channel TS at one time.
|
||||||
|
self._ts_lock = threading.Lock()
|
||||||
|
|
||||||
def to_lower(self, text):
|
def to_lower(self, text):
|
||||||
"""Returns a lowercase representation of text based on the IRC object's
|
"""Returns a lowercase representation of text based on the IRC object's
|
||||||
casemapping (rfc1459 or ascii)."""
|
casemapping (rfc1459 or ascii)."""
|
||||||
@ -1069,8 +1071,8 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
|
|||||||
self.apply_modes(channel, modes)
|
self.apply_modes(channel, modes)
|
||||||
|
|
||||||
# Use a lock so only one thread can change a channel's TS at once: this prevents race
|
# Use a lock so only one thread can change a channel's TS at once: this prevents race
|
||||||
# conditions from desyncing the channel list.
|
# conditions that would otherwise desync channel modes.
|
||||||
with self.ts_lock:
|
with self._ts_lock:
|
||||||
our_ts = self.channels[channel].ts
|
our_ts = self.channels[channel].ts
|
||||||
assert type(our_ts) == int, "Wrong type for our_ts (expected int, got %s)" % type(our_ts)
|
assert type(our_ts) == int, "Wrong type for our_ts (expected int, got %s)" % type(our_ts)
|
||||||
assert type(their_ts) == int, "Wrong type for their_ts (expected int, got %s)" % type(their_ts)
|
assert type(their_ts) == int, "Wrong type for their_ts (expected int, got %s)" % type(their_ts)
|
||||||
|
Loading…
Reference in New Issue
Block a user