Remove _chatLock and _internalLock
This commit is contained in:
parent
29359ad4fd
commit
ce75f5ee99
|
@ -88,8 +88,6 @@ class token:
|
||||||
# Locks
|
# Locks
|
||||||
self.processingLock = threading.Lock() # Acquired while there's an incoming packet from this user
|
self.processingLock = threading.Lock() # Acquired while there's an incoming packet from this user
|
||||||
self._bufferLock = threading.Lock() # Acquired while writing to packets buffer
|
self._bufferLock = threading.Lock() # Acquired while writing to packets buffer
|
||||||
self._internalLock = threading.Lock() # Acquired while performing internal operations on this token
|
|
||||||
self._chatLock = threading.Lock() # Acquired while performing chat operations
|
|
||||||
self._streamsLock = threading.Lock() # Acquired while joining/leaving streams
|
self._streamsLock = threading.Lock() # Acquired while joining/leaving streams
|
||||||
self._spectatorLock = threading.Lock() # Acquired while starting/stopping spectating
|
self._spectatorLock = threading.Lock() # Acquired while starting/stopping spectating
|
||||||
self._multiplayerLock = threading.Lock()# Acquired while joining/leaving streams
|
self._multiplayerLock = threading.Lock()# Acquired while joining/leaving streams
|
||||||
|
@ -143,8 +141,6 @@ class token:
|
||||||
:raises: exceptions.userAlreadyInChannelException()
|
:raises: exceptions.userAlreadyInChannelException()
|
||||||
exceptions.channelNoPermissionsException()
|
exceptions.channelNoPermissionsException()
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
self._chatLock.acquire()
|
|
||||||
if channelObject.name in self.joinedChannels:
|
if channelObject.name in self.joinedChannels:
|
||||||
raise exceptions.userAlreadyInChannelException()
|
raise exceptions.userAlreadyInChannelException()
|
||||||
if channelObject.publicRead == False and self.admin == False:
|
if channelObject.publicRead == False and self.admin == False:
|
||||||
|
@ -152,8 +148,6 @@ class token:
|
||||||
self.joinedChannels.append(channelObject.name)
|
self.joinedChannels.append(channelObject.name)
|
||||||
self.joinStream("chat/{}".format(channelObject.name))
|
self.joinStream("chat/{}".format(channelObject.name))
|
||||||
self.enqueue(serverPackets.channelJoinSuccess(self.userID, channelObject.clientName))
|
self.enqueue(serverPackets.channelJoinSuccess(self.userID, channelObject.clientName))
|
||||||
finally:
|
|
||||||
self._chatLock.release()
|
|
||||||
|
|
||||||
def partChannel(self, channelObject):
|
def partChannel(self, channelObject):
|
||||||
"""
|
"""
|
||||||
|
@ -161,12 +155,8 @@ class token:
|
||||||
|
|
||||||
:param channelObject: channel object
|
:param channelObject: channel object
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
self._chatLock.acquire()
|
|
||||||
self.joinedChannels.remove(channelObject.name)
|
self.joinedChannels.remove(channelObject.name)
|
||||||
self.leaveStream("chat/{}".format(channelObject.name))
|
self.leaveStream("chat/{}".format(channelObject.name))
|
||||||
finally:
|
|
||||||
self._chatLock.release()
|
|
||||||
|
|
||||||
def setLocation(self, latitude, longitude):
|
def setLocation(self, latitude, longitude):
|
||||||
"""
|
"""
|
||||||
|
@ -387,9 +377,6 @@ class token:
|
||||||
:param reason: Kick reason, used in logs. Default: "kick"
|
:param reason: Kick reason, used in logs. Default: "kick"
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
self._internalLock.acquire()
|
|
||||||
|
|
||||||
# Send packet to target
|
# Send packet to target
|
||||||
log.info("{} has been disconnected. ({})".format(self.username, reason))
|
log.info("{} has been disconnected. ({})".format(self.username, reason))
|
||||||
if message != "":
|
if message != "":
|
||||||
|
@ -398,8 +385,6 @@ class token:
|
||||||
|
|
||||||
# Logout event
|
# Logout event
|
||||||
logoutEvent.handle(self, deleteToken=self.irc)
|
logoutEvent.handle(self, deleteToken=self.irc)
|
||||||
finally:
|
|
||||||
self._internalLock.release()
|
|
||||||
|
|
||||||
def silence(self, seconds = None, reason = "", author = 999):
|
def silence(self, seconds = None, reason = "", author = 999):
|
||||||
"""
|
"""
|
||||||
|
@ -410,9 +395,6 @@ class token:
|
||||||
:param author: userID of who has silenced the user. Default: 999 (FokaBot)
|
:param author: userID of who has silenced the user. Default: 999 (FokaBot)
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
self._chatLock.acquire()
|
|
||||||
|
|
||||||
if seconds is None:
|
if seconds is None:
|
||||||
# Get silence expire from db if needed
|
# Get silence expire from db if needed
|
||||||
seconds = max(0, userUtils.getSilenceEnd(self.userID) - int(time.time()))
|
seconds = max(0, userUtils.getSilenceEnd(self.userID) - int(time.time()))
|
||||||
|
@ -428,8 +410,6 @@ class token:
|
||||||
|
|
||||||
# Send silenced packet to everyone else
|
# Send silenced packet to everyone else
|
||||||
glob.streams.broadcast("main", serverPackets.userSilenced(self.userID))
|
glob.streams.broadcast("main", serverPackets.userSilenced(self.userID))
|
||||||
finally:
|
|
||||||
self._chatLock.release()
|
|
||||||
|
|
||||||
def spamProtection(self, increaseSpamRate = True):
|
def spamProtection(self, increaseSpamRate = True):
|
||||||
"""
|
"""
|
||||||
|
@ -438,9 +418,6 @@ class token:
|
||||||
:param increaseSpamRate: set to True if the user has sent a new message. Default: True
|
:param increaseSpamRate: set to True if the user has sent a new message. Default: True
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
self._chatLock.acquire()
|
|
||||||
|
|
||||||
# Increase the spam rate if needed
|
# Increase the spam rate if needed
|
||||||
if increaseSpamRate:
|
if increaseSpamRate:
|
||||||
self.spamRate += 1
|
self.spamRate += 1
|
||||||
|
@ -448,8 +425,6 @@ class token:
|
||||||
# Silence the user if needed
|
# Silence the user if needed
|
||||||
if self.spamRate > 10:
|
if self.spamRate > 10:
|
||||||
self.silence(1800, "Spamming (auto spam protection)")
|
self.silence(1800, "Spamming (auto spam protection)")
|
||||||
finally:
|
|
||||||
self._chatLock.release()
|
|
||||||
|
|
||||||
def isSilenced(self):
|
def isSilenced(self):
|
||||||
"""
|
"""
|
||||||
|
@ -474,9 +449,6 @@ class token:
|
||||||
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
self._internalLock.acquire()
|
|
||||||
|
|
||||||
stats = userUtils.getUserStats(self.userID, self.gameMode)
|
stats = userUtils.getUserStats(self.userID, self.gameMode)
|
||||||
log.debug(str(stats))
|
log.debug(str(stats))
|
||||||
if stats is None:
|
if stats is None:
|
||||||
|
@ -488,8 +460,6 @@ class token:
|
||||||
self.totalScore = stats["totalScore"]
|
self.totalScore = stats["totalScore"]
|
||||||
self.gameRank = stats["gameRank"]
|
self.gameRank = stats["gameRank"]
|
||||||
self.pp = stats["pp"]
|
self.pp = stats["pp"]
|
||||||
finally:
|
|
||||||
self._internalLock.release()
|
|
||||||
|
|
||||||
def checkRestricted(self):
|
def checkRestricted(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user