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


Python error.AlreadyCancelled方法代码示例

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


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

示例1: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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 AlreadyCancelled [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 AlreadyCancelled [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: enqueuedJob

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例5: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例6: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例7: reset

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例8: testCallLater

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例9: test_cancelCancelledDelayedCall

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [as 别名]
def test_cancelCancelledDelayedCall(self):
        """
        Test that cancelling a DelayedCall which has already been cancelled
        raises the appropriate exception.
        """
        call = reactor.callLater(0, lambda: None)
        call.cancel()
        self.assertRaises(error.AlreadyCancelled, call.cancel) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:test_internet.py

示例10: cancel

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例11: reset

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [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

示例12: cancelTimeout

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

        If the timeout was already cancelled, this does nothing.
        """
        self.timeoutPeriod = None
        if self.timeoutCall:
            try:
                self.timeoutCall.cancel()
            except (error.AlreadyCalled, error.AlreadyCancelled):
                pass
            self.timeoutCall = None 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:15,代码来源:policies.py

示例13: abort_request

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [as 别名]
def abort_request(self, request):
        """Called to abort request on timeout"""
        self.timedout = True
        if not request.called:
            try:
                request.cancel()
            except error.AlreadyCancelled:
                return 
开发者ID:calston,项目名称:tensor,代码行数:10,代码来源:utils.py

示例14: remove_alarm

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [as 别名]
def remove_alarm(self, handle):
        """
        Remove an alarm.

        Returns True if the alarm exists, False otherwise
        """
        from twisted.internet.error import AlreadyCancelled, AlreadyCalled
        try:
            handle.cancel()
            return True
        except AlreadyCancelled:
            return False
        except AlreadyCalled:
            return False 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:16,代码来源:main_loop.py

示例15: getSession

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import AlreadyCancelled [as 别名]
def getSession(self, sessionInterface=None, forceNotSecure=False):
        """
        Check if there is a session cookie, and if not, create it.

        By default, the cookie with be secure for HTTPS requests and not secure
        for HTTP requests.  If for some reason you need access to the insecure
        cookie from a secure request you can set C{forceNotSecure = True}.

        @param forceNotSecure: Should we retrieve a session that will be
            transmitted over HTTP, even if this L{Request} was delivered over
            HTTPS?
        @type forceNotSecure: L{bool}
        """
        # Make sure we aren't creating a secure session on a non-secure page
        secure = self.isSecure() and not forceNotSecure

        if not secure:
            cookieString = b"TWISTED_SESSION"
            sessionAttribute = "_insecureSession"
        else:
            cookieString = b"TWISTED_SECURE_SESSION"
            sessionAttribute = "_secureSession"

        session = getattr(self, sessionAttribute)

        if session is not None:
            # We have a previously created session.
            try:
                # Refresh the session, to keep it alive.
                session.touch()
            except (AlreadyCalled, AlreadyCancelled):
                # Session has already expired.
                session = None

        if session is None:
            # No session was created yet for this request.
            cookiename = b"_".join([cookieString] + self.sitepath)
            sessionCookie = self.getCookie(cookiename)
            if sessionCookie:
                try:
                    session = self.site.getSession(sessionCookie)
                except KeyError:
                    pass
            # if it still hasn't been set, fix it up.
            if not session:
                session = self.site.makeSession()
                self.addCookie(cookiename, session.uid, path=b"/",
                               secure=secure)

        setattr(self, sessionAttribute, session)

        if sessionInterface:
            return session.getComponent(sessionInterface)

        return session 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:57,代码来源:server.py


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