예제 #1
0
class MysProcess(MyProcess):
    def __init__(self, msgh_mgr, msghname):
        MyProcess.__init__(self, msgh_mgr, msghname)
        self.eh = EHandler()
        self.eh.set_queue(self.queue)
        self.rqueue = None

    def _process(self):
        self.eh.register_timer(1000, TMTAGS.TEST, True)
        qid = self.msgh_mgr.findQueue("test_receive_process")
        self.rqueue = self.msgh_mgr.getQueue(qid)
        while True:
            msg = self.eh.getEvent()
            evtype = msg.get_eventype()
            msgtype = msg.get_msgtype()
            #print "------get message with evtype %s, msgtype %s, %s"%\
            #      (evtype, msgtype, os.getpid())
            if evtype == EVENTYPE.TIMEREXPIRE:
                self._send_timer_event()
            elif evtype == EVENTYPE.NORMALMSG:
                self._process_msg(msg)

    def _send_timer_event(self):
        #print "MysProcess::_send_timer_event"
        msg = MsgTestTimer()
        msg.set_text("denny is doing a test for timer" + \
                     str(datetime.datetime.now()))
        self.queue.send(self.rqueue, msg)

    def _process_msg(self, msg):
        msgtype = msg.get_type()
        if msgtype == MsgType.NORMAL_TEXT:
            print "got the response message", msg.get_body()
        else:
            print "MyTest::process_msg unsupport message"
예제 #2
0
class MysProcess(MyProcess):
    def __init__(self, msgh_mgr, msghname):
        MyProcess.__init__(self, msgh_mgr, msghname)
        self.eh = EHandler()
        self.eh.set_queue(self.queue)
        self.rqueue = None

    def _process(self):
        self.eh.register_timer(1000, TMTAGS.TEST, True)
        qid = self.msgh_mgr.findQueue("test_receive_process")
        self.rqueue = self.msgh_mgr.getQueue(qid)
        while True:
            msg = self.eh.getEvent()
            evtype = msg.get_eventype()
            msgtype = msg.get_msgtype()
            #print "------get message with evtype %s, msgtype %s, %s"%\
            #      (evtype, msgtype, os.getpid())
            if evtype == EVENTYPE.TIMEREXPIRE:
                self._send_timer_event()
            elif evtype == EVENTYPE.NORMALMSG:
                self._process_msg(msg)
            
    def _send_timer_event(self):
        #print "MysProcess::_send_timer_event"
        msg = MsgTestTimer()
        msg.set_text("denny is doing a test for timer" + \
                     str(datetime.datetime.now()))
        self.queue.send(self.rqueue, msg)

    def _process_msg(self, msg):
        msgtype = msg.get_type()
        if msgtype == MsgType.NORMAL_TEXT:
            print "got the response message", msg.get_body()
        else:
            print "MyTest::process_msg unsupport message"
예제 #3
0
class MyrProcess(MyProcess):
    def __init__(self, msgh_mgr, msghname):
        MyProcess.__init__(self, msgh_mgr, msghname)
        self.eh = EHandler()
        self.eh.set_queue(self.queue)

    def _process(self):
        while True:
            msg = self.eh.getEvent()
            self._process_msg(msg)

    def _process_msg(self, msg):
        print "got message", msg.get_body(), os.getpid()
예제 #4
0
class MyrProcess(MyProcess):
    def __init__(self, msgh_mgr, msghname):
        MyProcess.__init__(self, msgh_mgr, msghname)
        self.eh = EHandler()
        self.eh.set_queue(self.queue)

    def _process(self):
        while True:
            msg = self.eh.getEvent()
            self._process_msg(msg)

    def _process_msg(self, msg):
        print "got message", msg.get_body(), os.getpid()
예제 #5
0
class MyProcess(multiprocessing.Process):
    def __init__(self, msgh, msgh_name):
        multiprocessing.Process.__init__(self)
        self.msgh = msgh
        self.msgh_name = msgh_name
        self.queueid = self.msgh.registerQueue(self.msgh_name)
        self.queue = self.msgh.getQueue(self.queueid)
        self.ecode = 0
        self.eh = EHandler()
        self.eh.set_queue(self.queue)
        self.finish = False

    # totall control the process start and end
    def run(self):
        echo("process [%s/%s] start ..." % (self.pid, self.msgh_name))
        try:
            ret = self._process()
            ret = self._final()
        except Exception, e:
            print repr(e)
            import traceback
            traceback.print_exc()
예제 #6
0
class MyProcess(multiprocessing.Process):
    def __init__(self, msgh, msgh_name):
        multiprocessing.Process.__init__(self)
        self.msgh = msgh
        self.msgh_name = msgh_name
        self.queueid = self.msgh.registerQueue(self.msgh_name)
        self.queue = self.msgh.getQueue(self.queueid)
        self.ecode = 0
        self.eh = EHandler()
        self.eh.set_queue(self.queue)
        self.finish = False

    # totall control the process start and end
    def run(self):
        echo("process [%s/%s] start ..."%(self.pid, self.msgh_name))
        try:
            ret = self._process()
            ret = self._final()
        except Exception, e:
            print repr(e)
            import traceback
            traceback.print_exc()