Remove extra locks
This commit is contained in:
parent
0329847477
commit
176775f8f3
|
@ -88,8 +88,6 @@ class token:
|
|||
# Locks
|
||||
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._spectatorLock = threading.Lock() # Acquired while starting/stopping spectating
|
||||
self._multiplayerLock = threading.Lock()# Acquired while joining/leaving streams
|
||||
|
||||
# Set stats
|
||||
self.updateCachedStats()
|
||||
|
@ -189,13 +187,9 @@ class token:
|
|||
|
||||
:param host: host osuToken object
|
||||
"""
|
||||
try:
|
||||
# Stop spectating old client
|
||||
self.stopSpectating()
|
||||
|
||||
# Acquire token's lock
|
||||
self._spectatorLock.acquire()
|
||||
|
||||
# Set new spectator host
|
||||
self.spectating = host.token
|
||||
self.spectatingUserID = host.userID
|
||||
|
@ -229,8 +223,6 @@ class token:
|
|||
|
||||
# Log
|
||||
log.info("{} is spectating {}".format(self.username, host.username))
|
||||
finally:
|
||||
self._spectatorLock.release()
|
||||
|
||||
def stopSpectating(self):
|
||||
"""
|
||||
|
@ -239,10 +231,6 @@ class token:
|
|||
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
# Acquire token lock
|
||||
self._spectatorLock.acquire()
|
||||
|
||||
# Remove our userID from host's spectators
|
||||
if self.spectating is None:
|
||||
return
|
||||
|
@ -280,8 +268,6 @@ class token:
|
|||
# Set our spectating user to 0
|
||||
self.spectating = None
|
||||
self.spectatingUserID = 0
|
||||
finally:
|
||||
self._spectatorLock.release()
|
||||
|
||||
def updatePingTime(self):
|
||||
"""
|
||||
|
@ -298,9 +284,6 @@ class token:
|
|||
:param matchID: new match ID
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
self._multiplayerLock.acquire()
|
||||
|
||||
# Make sure the match exists
|
||||
if matchID not in glob.matches.matches:
|
||||
return
|
||||
|
@ -330,8 +313,6 @@ class token:
|
|||
# Alert the user if we have just joined a tourney match
|
||||
if match.isTourney:
|
||||
self.enqueue(serverPackets.notification("You are now in a tournament match."))
|
||||
finally:
|
||||
self._multiplayerLock.release()
|
||||
|
||||
def leaveMatch(self):
|
||||
"""
|
||||
|
@ -339,9 +320,6 @@ class token:
|
|||
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
self._multiplayerLock.acquire()
|
||||
|
||||
# Make sure we are in a match
|
||||
if self.matchID == -1:
|
||||
return
|
||||
|
@ -364,8 +342,6 @@ class token:
|
|||
|
||||
# Set slot to free
|
||||
match.userLeft(self)
|
||||
finally:
|
||||
self._multiplayerLock.release()
|
||||
|
||||
def kick(self, message="You have been kicked from the server. Please login again.", reason="kick"):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user