Note that there are some explanatory texts on larger screens.

plurals
  1. PODictionary in python
    primarykey
    data
    text
    <p>I'm creating a server-client communication, and I want to store some information in a dictionary, so I created a Global dictionary </p> <pre><code>global commandList commandList = {} </code></pre> <p>And when a client is connection to the server I'm trying to store some information in the following way</p> <pre><code>self.clientname = str( self.client_address ) commandList[self.clientname]['lastcommand'] = GET_SETUP </code></pre> <p>but I'm getting the following error</p> <pre><code>commandList[self.clientname]['isready'] = False KeyError: "('134.106.74.22', 49194)" </code></pre> <p><strong>UPDATED:</strong></p> <p>This is a part of the code.</p> <pre><code>class MCRequestHandler( SocketServer.BaseRequestHandler ): global clientsLock, postbox, rxQueue, disconnect, isRunning, commandList postbox = {} rxQueue = Queue.Queue() disconnect = {} commandList = {} clientsLock = threading.RLock() isRunning = {} def setup( self ): clientsLock.acquire() if len( postbox ) == 0: self.clientname = 'MasterClient' postbox['MasterClient'] = Queue.Queue() mess = str( self.client_address ); postbox['MasterClient'].put( self.createMessage( MASTER_CLIENT_CONNECTED, mess ) ) print "Client name: %s" % str( self.clientname ) self.request.settimeout( 0.1 ) else: #Send message to the master client self.clientname = str( self.client_address ) print "Client name:%s" % self.clientname postbox[self.clientname] = Queue.Queue() #Setting up the last command if not commandList.has_key( self.clientname ): commandList[self.clientname] = {} commandList[self.clientname]['lastcommand'] = GET_SETUP commandList[self.clientname]['isready'] = False self.request.settimeout( COMMANDTABLE[commandList[self.clientname]['lastcommand']]['timeout'] ) self.transNr = 0; self.start = True; isRunning[self.clientname] = True; disconnect[self.clientname] = True clientsLock.release() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload