当前位置: 首页>>代码示例>>Python>>正文


Python Thread.aborted方法代码示例

本文整理汇总了Python中gofer.common.Thread.aborted方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.aborted方法的具体用法?Python Thread.aborted怎么用?Python Thread.aborted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gofer.common.Thread的用法示例。


在下文中一共展示了Thread.aborted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_aborted

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def test_aborted(self, current):
     thread = GThread()
     current.return_value = thread
     event = getattr(thread, thread.ABORT)
     self.assertEqual(GThread.aborted(), event.isSet())
     # abort
     event.set()
     self.assertEqual(GThread.aborted(), event.isSet())
开发者ID:roshan,项目名称:gofer,代码行数:10,代码来源:test_common.py

示例2: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Run actions.
     """
     while not Thread.aborted():
         for plugin in Plugin.all():
             for action in plugin.actions:
                 plugin.pool.run(action)
         sleep(10)
开发者ID:jortel,项目名称:gofer,代码行数:11,代码来源:main.py

示例3: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Thread main.
     """
     delay = self._precision
     while not Thread.aborted():
         sleep(delay)
         for tracker in self.paths():
             self._sniff(tracker)
开发者ID:jortel,项目名称:gofer,代码行数:11,代码来源:pmon.py

示例4: open

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def open(self):
     """
     Open the reader.
     """
     while not Thread.aborted():
         try:
             self.reader.open()
             break
         except Exception:
             log.exception(self.getName())
             sleep(30)
开发者ID:pombredanne,项目名称:gofer,代码行数:13,代码来源:consumer.py

示例5: _fn

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def _fn(thing, *args, **kwargs):
     repair = lambda: None
     while not Thread.aborted():
         try:
             repair()
             return fn(thing, *args, **kwargs)
         except _NotFound, e:
             raise NotFound(*e.args)
         except LinkError:
             sleep(DELAY)
             repair = thing.repair
开发者ID:pombreda,项目名称:gofer,代码行数:13,代码来源:reliability.py

示例6: accept

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def accept(self, socket):
     """
     Accept requests.
     :param socket: An open socket.
     :type socket: socket.socket
     """
     while not Thread.aborted():
         client, address = socket.accept()
         try:
             self.accepted(client)
         finally:
             client.close()
开发者ID:darinlively,项目名称:gofer,代码行数:14,代码来源:manager.py

示例7: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Main consumer loop.
     """
     self.reader = Reader(self.node, self.url)
     self.reader.authenticator = self.authenticator
     self.open()
     try:
         while not Thread.aborted():
             self.read()
     finally:
         self.close()
开发者ID:pombredanne,项目名称:gofer,代码行数:14,代码来源:consumer.py

示例8: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Read the pending queue and dispatch requests
     to the plugin thread pool.
     """
     while not Thread.aborted():
         request = self.pending.get()
         try:
             task = Task(self.plugin, request, self.pending.commit)
             self.plugin.pool.run(task)
         except Exception:
             self.pending.commit(request.sn)
             log.exception(request.sn)
开发者ID:pombreda,项目名称:gofer,代码行数:15,代码来源:rmi.py

示例9: purge

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def purge(self, url=None):
     """
     Purge (drain) all queued messages.
     :param url: The broker URL.
     :type url: str
     """
     url = url or self.url
     with Reader(self, url=url) as reader:
         while not Thread.aborted():
             message = reader.get()
             if message:
                 message.ack()
             else:
                 break
开发者ID:jortel,项目名称:gofer,代码行数:16,代码来源:model.py

示例10: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Main run loop; processes input queue.
     """
     while not Thread.aborted():
         message = self.queue.get()
         if message == Worker.HALT:
             self.queue.put(message)
             return
         call = message
         try:
             call()
         except Exception:
             log.exception(str(call))
开发者ID:jortel,项目名称:gofer,代码行数:16,代码来源:threadpool.py

示例11: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Read the pending queue and dispatch requests
     to the plugin thread pool.
     """
     while not Thread.aborted():
         request = self.pending.get()
         try:
             pending = self.pending
             plugin = self.select_plugin(request)
             transaction = Transaction(plugin, pending, request)
             task = Task(transaction)
             plugin.pool.run(task)
         except Exception:
             self.pending.commit(request.sn)
             log.exception(request.sn)
开发者ID:pombredanne,项目名称:gofer,代码行数:18,代码来源:rmi.py

示例12: run

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def run(self):
     """
     Main run loop; processes input queue.
     """
     while not Thread.aborted():
         call = self.queue.get()
         if call == 1:
             # # busy
             continue
         if not call:
             # termination requested
             return
         try:
             call()
         except Exception:
             log.exception(utf8(call))
开发者ID:darinlively,项目名称:gofer,代码行数:18,代码来源:threadpool.py

示例13: _fn

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def _fn(thing, *args, **kwargs):
     repair = lambda: None
     while not Thread.aborted():
         try:
             repair()
             return fn(thing, *args, **kwargs)
         except _NotFound as e:
             raise NotFound(*e.args)
         except LinkError as le:
             log.warning(str(le))
             repair = thing.repair
             sleep(DELAY)
         except ConnectionError as pe:
             log.warning(str(pe))
             repair = thing.repair
             sleep(DELAY)
开发者ID:jortel,项目名称:gofer,代码行数:18,代码来源:reliability.py

示例14: _fn

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
 def _fn(messenger, *args, **kwargs):
     repair = lambda: None
     while not Thread.aborted():
         try:
             repair()
             return fn(messenger, *args, **kwargs)
         except ChannelError, le:
             if le.code != 404:
                 log.error(utf8(le))
                 repair = messenger.repair
                 sleep(DELAY)
             else:
                 raise NotFound(*le.args)
         except CONNECTION_EXCEPTIONS, pe:
             log.error(utf8(pe))
             repair = messenger.repair
             sleep(DELAY)
开发者ID:darinlively,项目名称:gofer,代码行数:19,代码来源:reliability.py

示例15: get_reply

# 需要导入模块: from gofer.common import Thread [as 别名]
# 或者: from gofer.common.Thread import aborted [as 别名]
    def get_reply(self, sn, reader):
        """
        Get the reply matched by serial number.
        :param sn: The request serial number.
        :type sn: str
        :param reader: A reader.
        :type reader: gofer.messaging.consumer.Reader
        :return: The matched reply document.
        :rtype: Document
        """
        timer = Timer()
        timeout = float(self.wait)

        while not Thread.aborted():
            timer.start()
            document = reader.search(sn, int(timeout))
            timer.stop()
            elapsed = timer.duration()
            if elapsed > timeout:
                raise RequestTimeout(sn, self.wait)
            else:
                timeout -= elapsed

            if not document:
                raise RequestTimeout(sn, self.wait)

            # rejected
            if document.status == 'rejected':
                raise DocumentError(
                    document.code,
                    document.description,
                    document.document,
                    document.details)

            # accepted | started
            if document.status in ('accepted', 'started'):
                continue

            # progress reported
            if document.status == 'progress':
                self.on_progress(document)
                continue

            # reply
            return self.on_reply(document)
开发者ID:jortel,项目名称:gofer,代码行数:47,代码来源:policy.py


注:本文中的gofer.common.Thread.aborted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。