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


Python error.AlreadyCalled方法代码示例

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


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

示例1: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def cancel(self):
        """Unschedule this call

        @raise AlreadyCancelled: Raised if this call has already been
        unscheduled.

        @raise AlreadyCalled: Raised if this call has already been made.
        """
        if self.cancelled:
            raise error.AlreadyCancelled
        elif self.called:
            raise error.AlreadyCalled
        else:
            self.canceller(self)
            self.cancelled = 1
            if self.debug:
                self._str = bytes(self)
            del self.func, self.args, self.kw 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:base.py

示例2: reset

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def reset(self, secondsFromNow):
        """Reschedule this call for a different time

        @type secondsFromNow: C{float}
        @param secondsFromNow: The number of seconds from the time of the
        C{reset} call at which this call will be scheduled.

        @raise AlreadyCancelled: Raised if this call has been cancelled.
        @raise AlreadyCalled: Raised if this call has already been made.
        """
        if self.cancelled:
            raise error.AlreadyCancelled
        elif self.called:
            raise error.AlreadyCalled
        else:
            newTime = self.seconds() + secondsFromNow
            if newTime < self.time:
                self.delayed_time = 0
                self.time = newTime
                self.resetter(self)
            else:
                self.delayed_time = newTime - self.time 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:base.py

示例3: delay

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def delay(self, secondsLater):
        """Reschedule this call for a later time

        @type secondsLater: C{float}
        @param secondsLater: The number of seconds after the originally
        scheduled time for which to reschedule this call.

        @raise AlreadyCancelled: Raised if this call has been cancelled.
        @raise AlreadyCalled: Raised if this call has already been made.
        """
        if self.cancelled:
            raise error.AlreadyCancelled
        elif self.called:
            raise error.AlreadyCalled
        else:
            self.delayed_time += secondsLater
            if self.delayed_time < 0:
                self.activate_delay()
                self.resetter(self) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:base.py

示例4: test_cancelCalledDelayedCallAsynchronous

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def test_cancelCalledDelayedCallAsynchronous(self):
        """
        Test that cancelling a DelayedCall after it has run its function
        raises the appropriate exception.
        """
        d = Deferred()
        def check():
            try:
                self.assertRaises(error.AlreadyCalled, call.cancel)
            except:
                d.errback()
            else:
                d.callback(None)
        def later():
            reactor.callLater(0, check)
        call = reactor.callLater(0, later)
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:test_internet.py

示例5: enqueuedJob

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def enqueuedJob(self):
        """
        Reschedule the work check loop to run right now. This should be called in response to "external" activity that
        might want to "speed up" the job queue polling because new work may have been added.
        """

        # Only need to do this if the actual poll interval is greater than the default rapid value
        if self._actualPollInterval == self.queuePollInterval:
            return

        # Bump time of last work so that we go back to the rapid (default) polling interval
        self._timeOfLastWork = time.time()

        # Reschedule the outstanding delayed call (handle exceptions by ignoring if its already running or
        # just finished)
        try:
            if self._workCheckCall is not None:
                self._workCheckCall.reset(0)
        except (AlreadyCalled, AlreadyCancelled):
            pass 
开发者ID:apple,项目名称:ccs-twistedextensions,代码行数:22,代码来源:queue.py

示例6: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def cancel(self):
        """Unschedule this call

        @raise AlreadyCancelled: Raised if this call has already been
        unscheduled.

        @raise AlreadyCalled: Raised if this call has already been made.
        """
        if self.cancelled:
            raise error.AlreadyCancelled
        elif self.called:
            raise error.AlreadyCalled
        else:
            self.canceller(self)
            self.cancelled = 1
            if self.debug:
                self._repr = repr(self)
            del self.func, self.args, self.kw 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:20,代码来源:base.py

示例7: test_cancelCalledDelayedCallSynchronous

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def test_cancelCalledDelayedCallSynchronous(self):
        """
        Test that cancelling a DelayedCall in the DelayedCall's function as
        that function is being invoked by the DelayedCall raises the
        appropriate exception.
        """
        d = Deferred()
        def later():
            try:
                self.assertRaises(error.AlreadyCalled, call.cancel)
            except:
                d.errback()
            else:
                d.callback(None)
        call = reactor.callLater(0, later)
        return d 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:18,代码来源:test_internet.py

示例8: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def cancel(self):
        """Unschedule this call

        @raise AlreadyCancelled: Raised if this call has already been
        unscheduled.

        @raise AlreadyCalled: Raised if this call has already been made.
        """
        if self.cancelled:
            raise error.AlreadyCancelled
        elif self.called:
            raise error.AlreadyCalled
        else:
            self.canceller(self)
            self.cancelled = 1
            if self.debug:
                self._str = str(self)
            del self.func, self.args, self.kw 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:20,代码来源:clock.py

示例9: reset

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def reset(self, secondsFromNow):
        """Reschedule this call for a different time

        @type secondsFromNow: C{float}
        @param secondsFromNow: The number of seconds from the time of the
        C{reset} call at which this call will be scheduled.

        @raise AlreadyCancelled: Raised if this call has been cancelled.
        @raise AlreadyCalled: Raised if this call has already been made.
        """
        if self.cancelled:
            raise error.AlreadyCancelled
        elif self.called:
            raise error.AlreadyCalled
        else:
            if self.seconds is None:
                new_time = seconds() + secondsFromNow
            else:
                new_time = self.seconds() + secondsFromNow
            if new_time < self.time:
                self.delayed_time = 0
                self.time = new_time
                self.resetter(self)
            else:
                self.delayed_time = new_time - self.time 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:27,代码来源:base.py

示例10: testCallLater

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def testCallLater(self):
        # add and remove a callback
        def bad():
            raise RuntimeError, "this shouldn't have been called"
        i = reactor.callLater(0.1, bad)
        i.cancel()

        self.assertRaises(error.AlreadyCancelled, i.cancel)

        d = defer.Deferred()
        i = reactor.callLater(0.5, self._callback, d, 1, a=1)
        start = time.time()

        def check(ignored):
            self.assertApproximates(self._calledTime, start + 0.5, 0.2 )
            self.assertRaises(error.AlreadyCalled, i.cancel)
            del self._called
            del self._calledTime
        d.addCallback(check)
        return d 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:22,代码来源:test_internet.py

示例11: cancelTimeout

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def cancelTimeout(self):
        """
        Cancel the timeout.

        If the timeout was already cancelled, this does nothing.
        """
        if self.timeoutCall:
            try:
                self.timeoutCall.cancel()
            except error.AlreadyCalled:
                pass
            self.timeoutCall = None 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:14,代码来源:policies.py

示例12: testAdvanceCancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def testAdvanceCancel(self):
        """
        Test attempting to cancel the call in a callback.

        AlreadyCalled should be raised, not for example a ValueError from
        removing the call from Clock.calls. This requires call.called to be
        set before the callback is called.
        """
        c = task.Clock()
        def cb():
            self.assertRaises(error.AlreadyCalled, call.cancel)
        call = c.callLater(1, cb)
        c.advance(1) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:test_task.py

示例13: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def cancel(self):
        """
        Cancel the delayed call to this ``Timeout``'s ``action``.
        """
        try:
            self._delay_call.cancel()
        except AlreadyCalled:
            # This Timeout may have triggered protocol.abortConnection which
            # will attempt to cancel...this timeout...
            pass 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:12,代码来源:_protocol.py

示例14: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def cancel(self):

        """Cancels the timer if it was running, does nothing otherwise"""

        try:
            self.delayed_call.cancel()
            self.status = False
        except (AttributeError, error.AlreadyCalled, error.AlreadyCancelled):
            pass 
开发者ID:smartbgp,项目名称:yabgp,代码行数:11,代码来源:timer.py

示例15: reset

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCalled [as 别名]
def reset(self, seconds_fromnow):
        """Resets an already running timer, or starts it if it wasn't running.

        :param seconds_fromnow : restart timer
        """

        try:
            self.status = True
            self.delayed_call.reset(seconds_fromnow)
        except (AttributeError, error.AlreadyCalled, error.AlreadyCancelled):
            self.delayed_call = reactor.callLater(seconds_fromnow, self.callable) 
开发者ID:smartbgp,项目名称:yabgp,代码行数:13,代码来源:timer.py


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