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