Пример #1
0
    def watchdog(self):
        """This function runs a multiprocessing queue
		so that each arduino handler won't lock while
		waiting from info to be done
		"""
        global DAEMON_RUNNING

        while DAEMON_RUNNING:
            #self.cv.acquire()
            try:
                #self.cv.wait(10)
                for (id, arduino) in self.arduino_handlers.iteritems():
                    if not arduino.in_queue.empty():
                        msg = arduino.in_queue.get()
                        print 'There is info on the arduino#%s query!' % id
                        print '   Handling info: %s' % msg
                        for listener in arduino.getListeners():
                            print '     Sending to listener %s' % listener
                            new_process = multiprocessing.Process(
                                target=listener.recv_msg,
                                args=(msg, arduino.out_queue.put_nowait))
                            new_process.daemonic = True
                            new_process.start()

            except KeyboardInterrupt:
                DAEMON_RUNNING = False
            finally:
                #self.cv.release()
                pass

            time.sleep(0.001)

        pass
Пример #2
0
	def watchdog(self):
		"""This function runs a multiprocessing queue
		so that each arduino handler won't lock while
		waiting from info to be done
		"""
		global DAEMON_RUNNING

		while DAEMON_RUNNING:
			#self.cv.acquire()
			try:
				#self.cv.wait(10)
				for (id,arduino) in self.arduino_handlers.iteritems():
					if not arduino.in_queue.empty():
						msg = arduino.in_queue.get()
						print 'There is info on the arduino#%s query!' % id
						print '   Handling info: %s' % msg
						for listener in arduino.getListeners():
							print '     Sending to listener %s' % listener
							new_process = multiprocessing.Process(target=listener.recv_msg,
									args=(msg, arduino.out_queue.put_nowait))
							new_process.daemonic = True
							new_process.start()

			except KeyboardInterrupt:
				DAEMON_RUNNING = False
			finally:
				#self.cv.release()
				pass

			time.sleep(0.001)
		
			
		pass
	def loop(self):
		"""This function runs a multiprocessing queue
		so that each arduino handler won't lock while
		waiting from info to be done
		"""
		global DAEMON_RUNNING

		pool = multiprocessing.Pool(processes=6)
		while DAEMON_RUNNING:
			self.cv.acquire()
			try:
				self.cv.wait(10)
				for (id,arduino) in self.arduino_handlers.iteritems():
					if not arduino.in_queue.empty():
						for listener in arduino.getListeners():
							pool.apply_async(listener.recv_msg, [msg,
								arduino.in_queue])

			except KeyboardInterrupt:
				DAEMON_RUNNING = False
			finally:
				self.cv.release()
		pass
    def loop(self):
        """This function runs a multiprocessing queue
		so that each arduino handler won't lock while
		waiting from info to be done
		"""
        global DAEMON_RUNNING

        pool = multiprocessing.Pool(processes=6)
        while DAEMON_RUNNING:
            self.cv.acquire()
            try:
                self.cv.wait(10)
                for (id, arduino) in self.arduino_handlers.iteritems():
                    if not arduino.in_queue.empty():
                        for listener in arduino.getListeners():
                            pool.apply_async(listener.recv_msg,
                                             [msg, arduino.in_queue])

            except KeyboardInterrupt:
                DAEMON_RUNNING = False
            finally:
                self.cv.release()
        pass