Example #1
0
 def start(self, silent=False):
     if self.is_running():
         if silent:
             return
         raise RuntimeError('%s already running' % class_name(self))
     self.greenlet = self.greenlet_class.spawn(self.run)
     self.greenlet.join(0)
     return self.greenlet
Example #2
0
 def __repr__(self):
     buf = StringIO()
     buf.write('<%s socket=%s' % (class_name(self),
                                  repr_socket(self.socket)))
     if self.topic is not None:
         buf.write(' topic=%r' % self.topic)
     buf.write('>')
     return buf.getvalue()
Example #3
0
 def __repr__(self):
     buf = StringIO()
     buf.write('<%s app=%r' % (class_name(self), self.app))
     if self.info is not None:
         buf.write(' info=%r' % self.info)
     sockets = ', '.join(repr_socket(s) for s in self.sockets)
     buf.write(' sockets=[%s]' % sockets)
     if self.reply_socket is not None:
         buf.write(' reply_socket=%s' % repr_socket(self.reply_socket))
     buf.write('>')
     return buf.getvalue()
Example #4
0
 def __repr__(self):
     buf = StringIO()
     buf.write('<%s' % class_name(self))
     if self.info:
         buf.write(' info=%r' % (self.info,))
     buf.write(' socket=%s' % repr_socket(self.socket))
     if self.collector is not None:
         buf.write(' collector=%r' % self.collector)
     if self.timeout is not None:
         buf.write(' timeout=%.3f' % self.timeout)
     buf.write('>')
     return buf.getvalue()
Example #5
0
 def __call__(self):
     # should be implemented by subclass.
     raise NotImplementedError('%s has no __call__ implementation'
                               '' % class_name(self))
Example #6
0
 def wait(self, timeout=None):
     if not self.is_running():
         raise RuntimeError('%s not running' % class_name(self))
     self.greenlet.join(timeout)
Example #7
0
 def stop(self, block=True, silent=False):
     if not self.is_running():
         if silent:
             return
         raise RuntimeError('%s not running' % class_name(self))
     self.greenlet.kill(block=block)
Example #8
0
 def __call__(self):
     # should be implemented by subclass.
     raise NotImplementedError('{0} has no __call__ implementation'
                               ''.format(class_name(self)))
Example #9
0
 def __repr__(self):
     return '<{0} info={1!r}>'.format(class_name(self), self.info)
Example #10
0
 def stop(self, silent=False):
     if not self.is_running():
         if silent:
             return
         raise RuntimeError('{0} not running'.format(class_name(self)))
     self.greenlet.kill(block=True)