def main_loop(self):
rlist = []
rlist.append(self.__pipe.inform)
timeout = 10
print "Total threads: {0}".format(threading.activeCount())
try:
while self.__running:
readable, _, _ = select.select(rlist, [], [], timeout)
if not readable:
continue
if self.__pipe.inform in readable:
try:
message = self.__pipe.read(256)
except OSError, exc:
logger.warn("[Error %d] appeared at reading pipe" %
exc.errno)
continue
if len(message) == 0:
continue
pdu_id = message.split()[0].split('.')[-2]
pdu_index = self.to_index(int(pdu_id))
logger.info("Assign message to pdu {0}".format(pdu_id))
self.__pdus[pdu_index].handle_message(message)
except KeyboardInterrupt:
logger.error("Break by user.")
except Exception, ex:
logger.error("{0}: {1}".format(sys._getframe().f_code.co_name, ex))
finally:
logger.info("vIPI Appliance service exits.")
self.__pipe.close()
评论列表
文章目录