def worker_process(self, log_queue): """ Simple multi-processing target that uses the helper log configuration in applog, and logs the current process name and an expected string. """ applog.process_log_configure(log_queue) # The root logger has now been created for this process, along with the # queue handler. Get a reference to the root_log and write a debug log # entry. In a real application the module level log = # logging.getLogger(__name__) still will be called, but then the log # module level variable will be overwritten witht the root logger # created in the applog.process_log_configure call above. root_log = logging.getLogger() proc_name = multiprocessing.current_process().name root_log.debug("%s Sub process debug log info", proc_name)
def run(self, log_queue, delay_time, results, control): """ Main infinite loop for acquiring from hardware device. Searches for any entry on the control queue to indicate a poison pill. Read from the hardware device at every pass, and if the current data queue is empty (by reading from it in a different process), add it to the data queue. """ applog.process_log_configure(log_queue) import_str = "devices.{0}()".format(self.device_name) log.debug("Import of %s", import_str) device = eval(import_str) log.debug("Start of while loop with delay [%s]", delay_time) while True: if control.full(): log.debug("Control queue full, exit poison pill") self.print_exit_stats() break self.read_count += 1 msg = (self.read_count, device.read()) if results.empty(): try: results.put(msg, block=False) # Silent failures on exit if you don't catch this exception except Queue.Full: pass if delay_time is not None: time.sleep(delay_time) log.debug("End of run while")