示例#1
0
文件: pool.py 项目: dsuch/gevent
 def kill(self, exception=GreenletExit, block=True, timeout=None):
     """
     Kill all greenlets being tracked by this group.
     """
     timer = Timeout._start_new_or_dummy(timeout)
     try:
         try:
             while self.greenlets:
                 for greenlet in list(self.greenlets):
                     if greenlet not in self.dying:
                         try:
                             kill = greenlet.kill
                         except AttributeError:
                             _kill(greenlet, exception)
                         else:
                             kill(exception, block=False)
                         self.dying.add(greenlet)
                 if not block:
                     break
                 joinall(self.greenlets)
         except Timeout as ex:
             if ex is not timer:
                 raise
     finally:
         timer.cancel()
示例#2
0
 def kill(self, exception=GreenletExit, block=True, timeout=None):
     """
     Kill all greenlets being tracked by this group.
     """
     timer = Timeout._start_new_or_dummy(timeout)
     try:
         while self.greenlets:
             for greenlet in list(self.greenlets):
                 if greenlet in self.dying:
                     continue
                 try:
                     kill = greenlet.kill
                 except AttributeError:
                     _kill(greenlet, exception)
                 else:
                     kill(exception, block=False)
                 self.dying.add(greenlet)
             if not block:
                 break
             joinall(self.greenlets)
     except Timeout as ex:
         if ex is not timer:
             raise
     finally:
         timer.cancel()
示例#3
0
文件: pool.py 项目: snaury/gevent
 def kill(self, exception=GreenletExit, block=True, timeout=None):
     timer = Timeout.start_new(timeout)
     try:
         try:
             while self.greenlets:
                 for greenlet in list(self.greenlets):
                     if greenlet not in self.dying:
                         try:
                             kill = greenlet.kill
                         except AttributeError:
                             _kill(greenlet, exception)
                         else:
                             kill(exception, block=False)
                         self.dying.add(greenlet)
                 if not block:
                     break
                 joinall(self.greenlets)
         except Timeout as ex:
             if ex is not timer:
                 raise
     finally:
         timer.cancel()
 def kill(self, exception=GreenletExit, block=True, timeout=None):
     timer = Timeout.start_new(timeout)
     try:
         try:
             while self.greenlets:
                 for greenlet in list(self.greenlets):
                     if greenlet not in self.dying:
                         try:
                             kill = greenlet.kill
                         except AttributeError:
                             _kill(greenlet, exception)
                         else:
                             kill(exception, block=False)
                         self.dying.add(greenlet)
                 if not block:
                     break
                 joinall(self.greenlets)
         except Timeout:
             ex = sys.exc_info()[1]
             if ex is not timer:
                 raise
     finally:
         timer.cancel()