Example #1
0
def recv_stdin(channel):
    buf = os.read(0, 1024)
    if not buf:
        event.abort()
    else:
        if buf.strip():
            evmsg.publish(channel, 'text/html', buf.strip())
        return True
Example #2
0
def recv_stdin(channel):
    buf = os.read(0, 1024)
    if not buf:
        event.abort()
    else:
        if buf.strip():
            evmsg.publish(channel, 'text/html', buf.strip())
        return True
Example #3
0
def got_error(eclass, e, tb):
    import traceback
    traceback.print_exception(eclass, e, tb)
    if FIX_ERROR:
        CONN.delete(MRJ['jid'], result_callback=got_response,
            result_callback_args = (CONN,))
        return
    print 'aborting now'
    event.abort()
Example #4
0
 def process_packet(self, p):
     """Process vaild RMC packet.
     """
     self.cnt = self.cnt + 1
     self.respond_to_sender(AckPacket(p.seq))
     if self.cnt >= exp_cnt:
         event.abort()
         return None
     else:
         return True
Example #5
0
 def process_packet(self, p):
     """Process vaild RMC packet.
     """
     self.p_in = self.p_in + 1
     if p.flags & packet.ACK:
         self.p_ack = self.p_ack + 1
         ##             self.add_write()
         if self.cnt < self.to_send:
             self.handle_write()
     if self.p_in >= self.to_send:
         print "t recv:", time.time() - self.t_start
         event.abort()
     return True
Example #6
0
def got_response(response, conn):
    global MRJ
    if 'jid' in response:
        if response['data'] == 'stop':
            print 'finishing'
            event.abort()
            return
        print 'got a response!', response
        MRJ = response
        dnum = response['jid'] if not PUT_ERROR else response['jid']-1
        conn.delete(dnum)
    else:
        print 'deleted'
        conn.reserve()
Example #7
0
def _sigint():
    event.abort()
Example #8
0
 def abort(self):
     # schedule an exception, because otherwise dispatch() will not exit if
     # there are timeouts scheduled
     self.schedule_call_global(0, self.greenlet.throw, api.GreenletExit)
     event.abort()
Example #9
0
 def __signal2_cb(sig):
     if sig:
         event.abort()
     else:
         os.kill(os.getpid(), signal.SIGUSR1)
Example #10
0
 def on_read_timeout(self):
     print 'read timeout!'
     event.abort()
     return
Example #11
0
    def run(self):
        global GLOBAL_TERMINATE
        while GLOBAL_TERMINATE == False:
            the_input = sys.stdin.readline().strip()
            if the_input == 'restart':
                self._owner.DEBUG('server','Stand-by; Restarting entire server!','info')
                self._owner.shutdown(STREAM_SYSTEM_SHUTDOWN)
                self._owner.DEBUG('server','Server has been shutdown, restarting NOW!','info')
                GLOBAL_TERMINATE = False
                self._owner.__init__(['always'],True)

            elif the_input == 'sys_debug':
                print(sys.exc_info())
                print(traceback.print_exc())
            elif the_input.split(' ')[0] == 'restart':

                import modules
                reload(modules)
                for addon in modules.addons:
                    if addon().__class__.__name__.lower() == the_input.split(' ')[1].lower():
                        if issubclass(addon,PlugIn):
                            if addon().__class__.__name__ in self._owner.__dict__:
            #                    self.DEBUG('server','Plugging-out?','info')

                                self._owner.DEBUG('server','Plugging %s out of %s.'%(addon(),s),'stop')
                                if addon().DBG_LINE in self._owner.debug_flags:
                                    self._owner.debug_flags.remove(addon().DBG_LINE)
                                if getattr(addon(),'_exported_methods',None) != None:
                                    for method in addon()._exported_methods: del self._owner.__dict__[method.__name__]
                                if getattr(addon(),'_old_owners_methods',None) != None:
                                    for method in addon()._old_owners_methods: self._owner.__dict__[method.__name__]=method
                                del self._owner.__dict__[addon().__class__.__name__]
                                if 'plugout' in addon().__class__.__dict__: addon().plugout()
                                self._owner.unfeature(addon.NS)

                                addon().PlugIn(s)
                            else:
                                addon().PlugIn(s)
                        else: self._owner.__dict__[addon.__class__.__name__]=addon()
                        self._owner.feature(addon.NS)

            elif the_input.split(' ')[0] == 'start':

                import modules
                reload(modules)
                for addon in modules.addons:
                    if addon().__class__.__name__.lower() == the_input.split(' ')[1].lower():
                        if issubclass(addon,PlugIn):
                            addon().PlugIn(s)
                        else: self._owner.__dict__[addon.__class__.__name__]=addon()
                        self._owner.feature(addon.NS)

            elif the_input.split(' ')[0] == 'stop':

                import modules
                reload(modules)
                for addon in modules.addons:
                    if addon().__class__.__name__.lower() == the_input.split(' ')[1].lower():
                        if issubclass(addon,PlugIn):
                            if addon().__class__.__name__ in self._owner.__dict__:
            #                    self.DEBUG('server','Plugging-out?','info')

                                self._owner.DEBUG('server','Plugging %s out of %s.'%(addon(),s),'stop')
                                if addon().DBG_LINE in self._owner.debug_flags:
                                    self._owner.debug_flags.remove(addon().DBG_LINE)
                                if getattr(addon(),'_exported_methods',None) != None:
                                    for method in addon()._exported_methods: del self._owner.__dict__[method.__name__]
                                if getattr(addon(),'_old_owners_methods',None) != None:
                                    for method in addon()._old_owners_methods: self._owner.__dict__[method.__name__]=method
                                del self._owner.__dict__[addon().__class__.__name__]
                                if 'plugout' in addon().__class__.__dict__: addon().plugout()
                            else:
                                self._owner.DEBUG('server','Error: Could not un-plug %s'%addon().__class__.__name__,'error')
                        else:
                            if getattr(addon(),'_exported_methods',None) != None:
                                for method in addon()._exported_methods: del self._owner.__dict__[method.__name__]
                            if getattr(addon(),'_old_owners_methods',None) != None:
                                for method in addon()._old_owners_methods: self._owner.__dict__[method.__name__]=method
                            del self._owner.__dict__[addon().__class__.__name__]
                            if 'plugout' in addon().__class__.__dict__: addon().plugout()
                        if addon().__class__.__name__ in self._owner.__dict__:
                            self._owner.DEBUG('server','Error: Could not un-plug %s'%addon().__class__.__name__,'error')
                        self._owner.unfeature(addon.NS)

            elif the_input == 'quit':
                GLOBAL_TERMINATE = True
                event.abort()
                break
            time.sleep(.01)
Example #12
0
 def __signal2_cb(sig):
     if sig:
         event.abort()
     else:
         os.kill(os.getpid(), signal.SIGUSR1)
Example #13
0
def _event_stop(*args):
    _event_running = False
    event.abort(*args)
Example #14
0
def _lib_out():
    event.abort()
Example #15
0
def _kb_handler(*args, **kw):
    """Just raise KeyboardInterrupt exception.
    """
    event.abort()
    raise KeyboardInterrupt()
Example #16
0
 def on_write_timeout(self):
     print "write timeout!"
     event.abort()
Example #17
0
 def _lib_out(self):
     if isinstance(self._socker,Socker_client): self._socker.destroy()
     event.abort()
     self.DEBUG('server',self._l(SERVER_SHUTDOWN_MSG),'info')
     self.shutdown(STREAM_SYSTEM_SHUTDOWN)
Example #18
0
def _event_stop(*args):
    _event_running = False
    event.abort(*args)
Example #19
0
 def wrapper():
     try:
         handler(signalnum, None)
     except:
         self.signal_exc_info = sys.exc_info()
         event.abort()
Example #20
0
 def abort(self):
     # schedule an exception, because otherwise dispatch() will not exit if
     # there are timeouts scheduled
     self.schedule_call_global(0, self.greenlet.throw, api.GreenletExit)
     event.abort()