Python twisted.internet.error.AlreadyCalled() Examples
The following are 30
code examples of twisted.internet.error.AlreadyCalled().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.internet.error
, or try the search function
.
Example #1
Source File: base.py From learn_python3_spider with MIT License | 7 votes |
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
Example #2
Source File: base.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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
Example #3
Source File: test_internet.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: base.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: base.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: base.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
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
Example #7
Source File: test_internet.py From python-for-android with Apache License 2.0 | 6 votes |
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
Example #8
Source File: base.py From python-for-android with Apache License 2.0 | 6 votes |
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)
Example #9
Source File: base.py From python-for-android with Apache License 2.0 | 6 votes |
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
Example #10
Source File: base.py From python-for-android with Apache License 2.0 | 6 votes |
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
Example #11
Source File: clock.py From landscape-client with GNU General Public License v2.0 | 6 votes |
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)
Example #12
Source File: clock.py From landscape-client with GNU General Public License v2.0 | 6 votes |
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
Example #13
Source File: clock.py From landscape-client with GNU General Public License v2.0 | 6 votes |
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
Example #14
Source File: test_internet.py From learn_python3_spider with MIT License | 6 votes |
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
Example #15
Source File: test_internet.py From learn_python3_spider with MIT License | 6 votes |
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
Example #16
Source File: base.py From learn_python3_spider with MIT License | 6 votes |
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)
Example #17
Source File: base.py From learn_python3_spider with MIT License | 6 votes |
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
Example #18
Source File: base.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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
Example #19
Source File: base.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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)
Example #20
Source File: queue.py From ccs-twistedextensions with Apache License 2.0 | 6 votes |
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
Example #21
Source File: test_internet.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
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
Example #22
Source File: _protocol.py From flocker with Apache License 2.0 | 5 votes |
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
Example #23
Source File: deferred_utils.py From voltha with Apache License 2.0 | 5 votes |
def _cancel_timer(self): try: self.timer.cancel() except AlreadyCalled: pass
Example #24
Source File: policies.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
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
Example #25
Source File: policies.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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
Example #26
Source File: test_task.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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)
Example #27
Source File: test_task.py From python-for-android with Apache License 2.0 | 5 votes |
def testAdvanceCancel(self): """ Test attemping 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)
Example #28
Source File: policies.py From python-for-android with Apache License 2.0 | 5 votes |
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
Example #29
Source File: test_task.py From learn_python3_spider with MIT License | 5 votes |
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)
Example #30
Source File: timer.py From yabgp with Apache License 2.0 | 5 votes |
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