예제 #1
0
    def _emulate(self, vals): 

        try:
            atom_time(vals['real'])

        except Exception as e:
            print "time atom error: %s" % e
            ru.cancel_main_thread()
예제 #2
0
    def _emulate(self, vals):

        try:
            # print "atom_memorye (%s)" % vals['size']
            atom_memory(int(vals['size']))

        except Exception as e:
            print "mem atom error: %s" % e
            ru.cancel_main_thread()
예제 #3
0
    def _emulate (self, vals): 

        try:
         # print "atom_memorye (%s)" % vals['size']
            atom_memory (int(vals['size']))

        except Exception as e:
            print "mem atom error: %s" % e
            ru.cancel_main_thread()
예제 #4
0
    def emulate(self, vals):

        try:
            self._verify(vals)
            print "emulate  %s" % vals
            self._work_queue.put(vals)

        except Exception as e:
            print 'emulation error: invalid data: %s' % vals
            ru.cancel_main_thread()
예제 #5
0
    def emulate(self, vals):

        try:
            self._verify(vals)
            print "emulate  %s" % vals
            self._work_queue.put(vals)

        except Exception as e:
            print 'emulation error: invalid data: %s' % vals
            ru.cancel_main_thread()
예제 #6
0
    def _default_state_cb(self, pilot, state=None):


        uid   = self.uid
        state = self.state

        self._log.info("[Callback]: pilot %s state: %s.", uid, state)

        if state == rps.FAILED and self._exit_on_error:
            self._log.error("[Callback]: pilot '%s' failed (exit)", uid)

            # There are different ways to tell main...
            ru.cancel_main_thread('int')
예제 #7
0
    def _emulate(self, vals):

        src = vals['src'] % {'tmp': self._tmpdir, 'pid': self._pid}
        rsize = int(vals['rsize'])
        tgt = vals['tgt'] % {'tmp': self._tmpdir, 'pid': self._pid}
        wsize = int(vals['wsize'])
        buf = int(vals['buf'])

        try:
            atom_storage(src, rsize, tgt, wsize, buf)

        except Exception as e:
            print "sto atom error: %s" % e
            ru.cancel_main_thread()
예제 #8
0
    def _emulate (self, vals):

        typ  =     vals['type']
        mode =     vals['mode']
        port = int(vals['port'])
        host =     vals.get('size')
        size = int(vals.get('size', 1))

        try:
            atom_network (typ, mode, host, port, size)

        except Exception as e:
            print "net atom error: %s" % e
            ru.cancel_main_thread()
예제 #9
0
    def _emulate(self, vals):

        typ = vals['type']
        mode = vals['mode']
        port = int(vals['port'])
        host = vals.get('size')
        size = int(vals.get('size', 1))

        try:
            atom_network(typ, mode, host, port, size)

        except Exception as e:
            print "net atom error: %s" % e
            ru.cancel_main_thread()
예제 #10
0
    def _emulate (self, vals):

        src   =     vals['src'  ] % { 'tmp' : self._tmpdir, 'pid' : self._pid   }
        rsize = int(vals['rsize'])
        tgt   =     vals['tgt'  ] % { 'tmp' : self._tmpdir, 'pid' : self._pid   }
        wsize = int(vals['wsize'])
        buf   = int(vals['buf'  ])

        try:
            atom_storage(src, rsize, tgt, wsize, buf)

        except Exception as e:
            print "sto atom error: %s" % e
            ru.cancel_main_thread()
    def run(self):

        try:
            print '%s start' % self.uid

            while not self.term.is_set():

                # print '%s run' % self.uid
                time.sleep(SLEEP)

                if self.num == 2 and self.pnum == 0:
                    print "2"
                    ru.raise_on(self.uid, RAISE_ON)

                if self.num == 5 and self.pnum == 1:
                    print "5"
                    ru.raise_on(self.uid, RAISE_ON)

                # check watchables
                for thing in self.to_watch:
                    if thing.is_alive():
                        print '%s event: thing %s is alive' % (self.uid,
                                                               thing.uid)
                    else:
                        print '%s event: thing %s has died' % (self.uid,
                                                               thing.uid)
                        ru.cancel_main_thread()
                        assert (False)  # we should never get here

                # check MainThread
                if not self.main.is_alive():
                    print '%s: main thread gone - terminate' % self.uid
                    self.stop()

            print '%s stop' % self.uid

        except Exception as e:
            print '%s error %s [%s]' % (self.uid, e, type(e))
            ru.cancel_main_thread()

        except SystemExit:
            print '%s exit' % (self.uid)
            # do *not* cancel main thread here!  We get here after the cancel
            # signal has been sent in the main loop above

        finally:
            print '%s final' % (self.uid)
    def run(self):

        try:
            print '%s start' % self.uid

            while not self.term.is_set():

              # print '%s run' % self.uid
                time.sleep(SLEEP)

                if self.num == 2 and self.pnum == 0:
                    print "2"
                    ru.raise_on(self.uid, RAISE_ON)

                if self.num == 5 and self.pnum == 1:
                    print "5"
                    ru.raise_on(self.uid, RAISE_ON)

                # check watchables
                for thing in self.to_watch:
                    if thing.is_alive():
                        print '%s event: thing %s is alive' % (self.uid, thing.uid)
                    else:
                        print '%s event: thing %s has died' % (self.uid, thing.uid)
                        ru.cancel_main_thread()
                        assert(False) # we should never get here

                # check MainThread
                if not self.main.is_alive():
                    print '%s: main thread gone - terminate' % self.uid
                    self.stop()

            print '%s stop' % self.uid


        except Exception as e:
            print '%s error %s [%s]' % (self.uid, e, type(e))
            ru.cancel_main_thread()
       
        except SystemExit:
            print '%s exit' % (self.uid)
            # do *not* cancel main thread here!  We get here after the cancel
            # signal has been sent in the main loop above
       
        finally:
            print '%s final' % (self.uid)
예제 #13
0
    def run(self):

        try:
            print '%s start' % self.uid

            while not self.term.is_set():

                # print '%s run' % self.uid
                time.sleep(SLEEP)

                if self.num == 2 and self.pnum == 0:
                    print "2"
                    ru.raise_on(self.uid, RAISE_ON)

                if self.num == 5 and self.pnum == 1:
                    print "5"
                    ru.raise_on(self.uid, RAISE_ON)

                for thing in self.to_watch:
                    if thing.is_alive():
                        print '%s event: thing %s is alive' % (self.uid,
                                                               thing.uid)
                    else:
                        print '%s event: thing %s has died' % (self.uid,
                                                               thing.uid)
                        ru.cancel_main_thread('usr2')
                        raise RuntimeError('thing %s has died - assert' %
                                           thing.uid)

            print '%s stop' % self.uid

        except Exception as e:
            print '%s error %s [%s]' % (self.uid, e, type(e))
            ru.cancel_main_thread('usr2')

        except SystemExit:
            print '%s exit' % (self.uid)
            # do *not* cancel main thread here!  We get here
        #ru.cancel_main_thread('usr2')

        except KeyboardInterrupt:
            print '%s intr' % (self.uid)
            ru.cancel_main_thread('usr2')

        finally:
            print '%s final' % (self.uid)
    def run(self):

        try:
            print '%s start' % self.uid

            while not self.term.is_set():

              # print '%s run' % self.uid
                time.sleep(SLEEP)

                if self.num == 2 and self.pnum == 0:
                    print "2"
                    ru.raise_on(self.uid, RAISE_ON)

                if self.num == 5 and self.pnum == 1:
                    print "5"
                    ru.raise_on(self.uid, RAISE_ON)

                for thing in self.to_watch:
                    if thing.is_alive():
                        print '%s event: thing %s is alive' % (self.uid, thing.uid)
                    else:
                        print '%s event: thing %s has died' % (self.uid, thing.uid)
                        ru.cancel_main_thread('usr2')
                        raise RuntimeError('thing %s has died - assert' % thing.uid)

            print '%s stop' % self.uid


        except Exception as e:
            print '%s error %s [%s]' % (self.uid, e, type(e))
            ru.cancel_main_thread('usr2')
       
        except SystemExit:
            print '%s exit' % (self.uid)
            # do *not* cancel main thread here!  We get here 
           #ru.cancel_main_thread('usr2')
       
        except KeyboardInterrupt:
            print '%s intr' % (self.uid)
            ru.cancel_main_thread('usr2')
       
        finally:
            print '%s final' % (self.uid)