def run(self): """ Loop forever consuming output from our SUA threads """ # Wait for output to start returning, and handle appropriately while True: # Get our log data output_packed = self.DATA_QUEUE.get() # If its a kill command, just post it if output_packed == G.CTRL_CMD_KILL: logger.debug("Logger killed...") # Close our logs cleanly for log in self.logfiles.keys(): self.logfiles[log].close() break if self.packed_data: output = protobuf.unpack_sensor_output(output_packed) else: output = output_packed # Log to file self.logfile.append(output) logger.debug("Logger closed.")
def run(self): """ Loop forever consuming output from our SUA threads """ # Wait for output to start returning, and handle appropriately while True: # Get our log data output_packed = self.DATA_QUEUE.get() # If its a kill command, just post it if output_packed == G.CTRL_CMD_KILL: logger.debug("Logger killed...") # Close our logs cleanly for log in self.logfiles.keys(): self.logfiles[log].close() break if self.packed_data: output = protobuf.unpack_sensor_output(output_packed) else: output = output_packed # Log to file self.logfile.append(output) logger.debug("Logger closed.")
def run(self): """ Loop until we fail relaying objects """ # Set our handler to close gracefully G.set_exit_handler(self.cleanup) if G.VERBOSE: print "Relaying data from socket to queue." while self.RUNNING: # Try to unpack it try: # Get our data data = G.read_socket_data(self.SOCK) # Unpack our sensor output data = ProtoBuf.unpack_sensor_output(data) except EOFError: if G.VERBOSE: print "RemoteQueue: Looks like our socket closed." break except: # Just die! if self.RUNNING: print "ERROR/RemoteQueue: Could not unpickle network data." break # update our machine name to indicate its origin data['MACHINE'] = self.address[0] + "-" + data['MACHINE'] # Write the data to our queue, if we can try: self.OUTPUT_QUEUE.put(data, False) except: if self.RUNNING: print "ERROR/RemoteQueue: Could not write to output queue." G.print_traceback() break # Close socket self.SOCK.close()
def run(self): """ Loop until we fail relaying objects """ # Set our handler to close gracefully G.set_exit_handler(self.cleanup) if G.VERBOSE: print "Relaying data from socket to queue." while self.RUNNING: # Try to unpack it try: # Get our data data = G.read_socket_data(self.SOCK) # Unpack our sensor output data = ProtoBuf.unpack_sensor_output(data) except EOFError: if G.VERBOSE: print "RemoteQueue: Looks like our socket closed." break except: # Just die! if self.RUNNING: print "ERROR/RemoteQueue: Could not unpickle network data." break # update our machine name to indicate its origin data['MACHINE'] = self.address[0] + "-" + data['MACHINE'] # Write the data to our queue, if we can try: self.OUTPUT_QUEUE.put(data, False) except: if self.RUNNING: print "ERROR/RemoteQueue: Could not write to output queue." G.print_traceback() break # Close socket self.SOCK.close()