Skip to content

Commit

Permalink
Add more comments and clean up server
Browse files Browse the repository at this point in the history
  • Loading branch information
UsualSpec committed Jul 3, 2024
1 parent f3b4a87 commit 4aad7c2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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({})

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4aad7c2

Please sign in to comment.