Removed locks - this is not threaded app
This commit is contained in:
parent
e993b2ef25
commit
a9325de8f9
@ -6,8 +6,6 @@ from twisted.internet.protocol import Factory
|
||||
import syncplay
|
||||
from syncplay.protocols import SyncServerProtocol
|
||||
import time
|
||||
import threading
|
||||
|
||||
|
||||
class SyncFactory(Factory):
|
||||
def __init__(self, password = '', banlist = None , isolateRooms = False):
|
||||
@ -18,8 +16,6 @@ class SyncFactory(Factory):
|
||||
self._rooms = {}
|
||||
self._roomStates = {}
|
||||
self.isolateRooms = isolateRooms
|
||||
self.roomUpdateLock = threading.RLock()
|
||||
self.roomUsersLock = threading.RLock()
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
return SyncServerProtocol(self)
|
||||
@ -50,13 +46,11 @@ class SyncFactory(Factory):
|
||||
self.broadcast(watcherProtocol, l)
|
||||
|
||||
def getWatcher(self, watcherProtocol):
|
||||
with self.roomUsersLock:
|
||||
for room in self._rooms.itervalues():
|
||||
if(room.has_key(watcherProtocol)):
|
||||
return room[watcherProtocol]
|
||||
|
||||
def getAllWatchers(self, watcherProtocol):
|
||||
with self.roomUsersLock:
|
||||
if(self.isolateRooms):
|
||||
room = self.getWatcher(watcherProtocol).room
|
||||
return self._rooms[room]
|
||||
@ -68,14 +62,11 @@ class SyncFactory(Factory):
|
||||
return watchers
|
||||
|
||||
def _removeWatcherFromTheRoom(self, watcherProtocol):
|
||||
with self.roomUsersLock:
|
||||
for room in self._rooms.itervalues():
|
||||
watcher = room.pop(watcherProtocol, None)
|
||||
return watcher
|
||||
|
||||
def _deleteRoomIfEmpty(self, room):
|
||||
with self.roomUpdateLock:
|
||||
with self.roomUsersLock:
|
||||
if (self._rooms[room] == {}):
|
||||
self._rooms.pop(room)
|
||||
self._roomStates.pop(room)
|
||||
@ -132,7 +123,6 @@ class SyncFactory(Factory):
|
||||
watcher = self.getWatcher(watcherProtocol)
|
||||
self.__updateWatcherPing(latencyCalculation, watcher)
|
||||
watcher.lastUpdate = time.time()
|
||||
with self.roomUpdateLock:
|
||||
if(watcher.file):
|
||||
if(position is not None):
|
||||
self.__updatePositionState(position, doSeek, watcher)
|
||||
@ -145,7 +135,6 @@ class SyncFactory(Factory):
|
||||
self.broadcastRoom(watcher, l)
|
||||
|
||||
def removeWatcher(self, watcherProtocol):
|
||||
with self.roomUsersLock:
|
||||
watcher = self._removeWatcherFromTheRoom(watcherProtocol)
|
||||
if(not watcher):
|
||||
return
|
||||
@ -162,7 +151,6 @@ class SyncFactory(Factory):
|
||||
return self.getWatcher(watcherProtocol).room
|
||||
|
||||
def watcherSetRoom(self, watcherProtocol, room):
|
||||
with self.roomUsersLock:
|
||||
watcher = self._removeWatcherFromTheRoom(watcherProtocol)
|
||||
if(not watcher):
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user