def run(self):
     "Continuously read messages over the network."
     while self.is_alive:
         msg_type = decode_int(self.sock.recv(1))
         data = messages.MESSAGES[msg_type].decode(self.sock)
         if msg_type == ENTRY_ASSIGNMENT or msg_type == ENTRY_ASSIGNMENT:
             TABLE.lock()
             if self.in_transaction:
                 self.add_item((msg_type, data))
             else:
                 self.begin_transaction()
                 self.add_item((msg_type, data))
                 self.end_transaction()
             TABLE.release()
Exemple #2
0
 def run(self):
     "Continuously read messages over the network."
     while self.is_alive:
         x = self.sock.recv(1)
         print "Read: " + str([x])
         msg_type = decode_int(x)
         data = messages.MESSAGES[msg_type].decode(self.sock)
         print "Read Data: " + str(data)
         if msg_type == ENTRY_ASSIGNMENT or msg_type == ENTRY_UPDATE:
             self.TABLE.lock()
             if self.in_transaction:
                 self.add_item((msg_type, data))
             else:
                 self.begin_transaction()
                 self.add_item((msg_type, data))
                 self.end_transaction()
             self.TABLE.release()