Exemplo n.º 1
0
 def _setup_ioloop(self):
     # Internal function called at the start of the actor. It builds the
     # event loop which will consume events on file descriptors
     # Inject self as the actor of this thread
     ioq = self.ioqueue
     self.requestloop = IOLoop(io=IOQueue(ioq, self) if ioq else None,
                               poll_timeout=self.params.poll_timeout,
                               logger=self.logger)
     # If CPU bound add the request handler to the request loop
     if self.cpubound:
         self.requestloop.add_handler('request',
                                       self.handle_fd_event,
                                       self.requestloop.READ)
     if self.is_process():
         random.seed()
         proc_name = "%s-%s" % (self.cfg.proc_name, self)
         if system.set_proctitle(proc_name):
             self.logger.debug('Set process title to %s', proc_name)
         #system.set_owner_process(cfg.uid, cfg.gid)
         if is_mainthread():
             self.logger.debug('Installing signals')
             self.signal_queue = ThreadQueue()
             for name in system.ALL_SIGNALS:
                 sig = getattr(signal, 'SIG%s' % name)
                 try:
                     signal.signal(sig, self._queue_signal)
                 except ValueError:
                     break
     self.mailbox = mailbox(self)
     set_local_data(self)
     self.logger.info('%s started at address %s', self, self.mailbox.address)
Exemplo n.º 2
0
 def _install_signals(self, actor):
     proc_name = "%s-%s" % (actor.cfg.proc_name, actor)
     if system.set_proctitle(proc_name):
         actor.logger.debug('Set process title to %s', proc_name)
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     if signal:
         actor.logger.debug('Installing signals')
         for sig in system.EXIT_SIGNALS:
             try:
                 actor._loop.add_signal_handler(
                     sig, self.handle_exit_signal, actor, sig)
             except ValueError:
                 pass
Exemplo n.º 3
0
 def _install_signals(self, actor):
     proc_name = "%s-%s" % (actor.cfg.proc_name, actor.name)
     if system.set_proctitle(proc_name):
         actor.logger.debug('Set process title to %s',
                            system.get_proctitle())
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     if signal:
         actor.logger.debug('Installing signals')
         for sig in system.EXIT_SIGNALS:
             try:
                 actor._loop.add_signal_handler(
                     sig, self.handle_exit_signal, actor, sig)
             except ValueError:
                 pass
Exemplo n.º 4
0
 def setup_event_loop(self, actor):
     event_loop = new_event_loop(io=self.io_poller(), logger=actor.logger,
                                 poll_timeout=actor.params.poll_timeout)
     actor.mailbox = self.create_mailbox(actor, event_loop)
     proc_name = "%s-%s" % (actor.cfg.proc_name, actor)
     if system.set_proctitle(proc_name):
         actor.logger.debug('Set process title to %s', proc_name)
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     if signal:
         actor.logger.debug('Installing signals')
         for sig in system.EXIT_SIGNALS:
             try:
                 actor.event_loop.add_signal_handler(
                     sig, self.handle_exit_signal, actor)
             except ValueError:
                 pass
Exemplo n.º 5
0
 def setup_event_loop(self, actor):
     event_loop = new_event_loop(io=self.io_poller(),
                                 logger=actor.logger,
                                 poll_timeout=actor.params.poll_timeout)
     actor.mailbox = self.create_mailbox(actor, event_loop)
     proc_name = "%s-%s" % (actor.cfg.proc_name, actor)
     if system.set_proctitle(proc_name):
         actor.logger.debug('Set process title to %s', proc_name)
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     if signal:
         actor.logger.debug('Installing signals')
         for sig in system.EXIT_SIGNALS:
             try:
                 actor.event_loop.add_signal_handler(
                     sig, self.handle_exit_signal, actor)
             except ValueError:
                 pass
Exemplo n.º 6
0
 def _install_signals(self, actor):
     proc_name = actor.cfg.proc_name
     if not self.is_arbiter():
         name = actor.name.split('.')[0]
         proc_name = "%s-%s" % (proc_name, name)
     if system.set_proctitle(proc_name):
         actor.logger.debug('Set process title to %s',
                            system.get_proctitle())
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     if signal:
         actor.logger.debug('Installing signals')
         for sig in system.EXIT_SIGNALS:
             try:
                 actor._loop.add_signal_handler(
                     sig, self.handle_exit_signal, actor, sig)
             except ValueError:
                 pass
Exemplo n.º 7
0
 def _install_signals(self, actor):
     proc_name = actor.cfg.proc_name
     if proc_name:
         if not self.is_arbiter():
             name = actor.name.split('.')[0]
             proc_name = "%s-%s" % (proc_name, name)
         if system.set_proctitle(proc_name):
             actor.logger.debug('Set process title to %s',
                                system.get_proctitle())
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     actor.logger.debug('Installing signals')
     loop = actor._loop
     for sig in system.SIGNALS:
         name = system.SIG_NAMES.get(sig)
         if name:
             handler = getattr(self, 'handle_%s' % name.lower(), None)
             if handler:
                 loop.add_signal_handler(sig, handler, actor, sig)
Exemplo n.º 8
0
 def _install_signals(self, actor):
     proc_name = actor.cfg.proc_name
     if proc_name:
         if not self.is_arbiter():
             name = actor.name.split('.')[0]
             proc_name = "%s-%s" % (proc_name, name)
         if system.set_proctitle(proc_name):
             actor.logger.debug('Set process title to %s',
                                system.get_proctitle())
     system.set_owner_process(actor.cfg.uid, actor.cfg.gid)
     actor.logger.debug('Installing signals')
     loop = actor._loop
     for sig in system.SIGNALS:
         name = system.SIG_NAMES.get(sig)
         if name:
             handler = getattr(self, 'handle_%s' % name.lower(), None)
             if handler:
                 loop.add_signal_handler(sig, handler, actor, sig)