From 4aad7c2e95f38149b4d38ce8e582536b93b94c3e Mon Sep 17 00:00:00 2001 From: UsualSpec <98665326+UsualSpec@users.noreply.github.com> Date: Wed, 3 Jul 2024 17:22:07 +0200 Subject: [PATCH] Add more comments and clean up server --- server/server.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/server/server.py b/server/server.py index 8913e8d..a4eea50 100644 --- a/server/server.py +++ b/server/server.py @@ -28,7 +28,7 @@ # Create password context for management pwdCtxt = CryptContext(schemes=["sha512_crypt"], deprecated="auto") - +# shared class for communication with CMeasurementApiServicer. Represents a client class ExternalClient(): def __init__(self, uid): # set up external Client class to manage each client in a separate thread. @@ -128,9 +128,8 @@ def purgeRequestNo(self, requestNo): if requestNo in self.responsedict: # only delete if existing. May not be the case if server generated error msg (e.g. timeout) del self.responsedict[requestNo] self.responsedictlock.release() -# shared class for communication with CMeasurementApiServicer - +# Store state of registered clients class ClientManager(): loggedInClients = dict({}) @@ -281,8 +280,8 @@ def getLatestMessages(self): # get the messages from the client manager and cle while True: print(pm.getNextMessageCli()) - -class OutCommunicator(): # communicate to other scripts and issue requests +# communicate to other scripts and issue requests +class OutCommunicator(): cliMessageQueue = qu() # a queue saving error/status messages outMessageQueues = {} # a set of queues saving error/status messages for the out communication only @@ -322,9 +321,7 @@ def __init__ (self, host, database, user, password): def createConnection(self): return postgres.connect(host=self.host,database=self.database,user=self.user,password=self.password) -# Implementation of server for measurement device management - - +# Implementation of gRPC methods class CMeasurementApiServicer(): def __init__(self, pgfac, allowedMgmtClients): # each thread should have an own postgres connection cursor for concurrent writes