Python twisted.internet.reactor.removeSystemEventTrigger() Examples
The following are 18
code examples of twisted.internet.reactor.removeSystemEventTrigger().
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.reactor
, or try the search function
.
Example #1
Source File: test_internet.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_removeSystemEventTrigger(self): """ A trigger removed with L{IReactorCore.removeSystemEventTrigger} should not be called when the event fires. """ eventType = 'test' events = [] def firstBeforeTrigger(): events.append('first') def secondBeforeTrigger(): events.append('second') self.addTrigger('before', eventType, firstBeforeTrigger) self.removeTrigger( self.addTrigger('before', eventType, secondBeforeTrigger)) self.assertEqual(events, []) reactor.fireSystemEvent(eventType) self.assertEqual(events, ['first'])
Example #2
Source File: test_internet.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_removeNonExistentSystemEventTrigger(self): """ Passing an object to L{IReactorCore.removeSystemEventTrigger} which was not returned by a previous call to L{IReactorCore.addSystemEventTrigger} or which has already been passed to C{removeSystemEventTrigger} should result in L{TypeError}, L{KeyError}, or L{ValueError} being raised. """ b = self.addTrigger('during', 'test', lambda: None) self.removeTrigger(b) self.assertRaises( TypeError, reactor.removeSystemEventTrigger, None) self.assertRaises( ValueError, reactor.removeSystemEventTrigger, b) self.assertRaises( KeyError, reactor.removeSystemEventTrigger, (b[0], ('xxx',) + b[1][1:]))
Example #3
Source File: test_internet.py From learn_python3_spider with MIT License | 6 votes |
def test_removeSystemEventTrigger(self): """ A trigger removed with L{IReactorCore.removeSystemEventTrigger} should not be called when the event fires. """ eventType = 'test' events = [] def firstBeforeTrigger(): events.append('first') def secondBeforeTrigger(): events.append('second') self.addTrigger('before', eventType, firstBeforeTrigger) self.removeTrigger( self.addTrigger('before', eventType, secondBeforeTrigger)) self.assertEqual(events, []) reactor.fireSystemEvent(eventType) self.assertEqual(events, ['first'])
Example #4
Source File: test_internet.py From learn_python3_spider with MIT License | 6 votes |
def test_removeNonExistentSystemEventTrigger(self): """ Passing an object to L{IReactorCore.removeSystemEventTrigger} which was not returned by a previous call to L{IReactorCore.addSystemEventTrigger} or which has already been passed to C{removeSystemEventTrigger} should result in L{TypeError}, L{KeyError}, or L{ValueError} being raised. """ b = self.addTrigger('during', 'test', lambda: None) self.removeTrigger(b) self.assertRaises( TypeError, reactor.removeSystemEventTrigger, None) self.assertRaises( ValueError, reactor.removeSystemEventTrigger, b) self.assertRaises( KeyError, reactor.removeSystemEventTrigger, (b[0], ('xxx',) + b[1][1:]))
Example #5
Source File: test_internet.py From python-for-android with Apache License 2.0 | 6 votes |
def test_removeSystemEventTrigger(self): """ A trigger removed with L{IReactorCore.removeSystemEventTrigger} should not be called when the event fires. """ eventType = 'test' events = [] def firstBeforeTrigger(): events.append('first') def secondBeforeTrigger(): events.append('second') self.addTrigger('before', eventType, firstBeforeTrigger) self.removeTrigger( self.addTrigger('before', eventType, secondBeforeTrigger)) self.assertEqual(events, []) reactor.fireSystemEvent(eventType) self.assertEqual(events, ['first'])
Example #6
Source File: test_internet.py From python-for-android with Apache License 2.0 | 6 votes |
def test_removeNonExistentSystemEventTrigger(self): """ Passing an object to L{IReactorCore.removeSystemEventTrigger} which was not returned by a previous call to L{IReactorCore.addSystemEventTrigger} or which has already been passed to C{removeSystemEventTrigger} should result in L{TypeError}, L{KeyError}, or L{ValueError} being raised. """ b = self.addTrigger('during', 'test', lambda: None) self.removeTrigger(b) self.assertRaises( TypeError, reactor.removeSystemEventTrigger, None) self.assertRaises( ValueError, reactor.removeSystemEventTrigger, b) self.assertRaises( KeyError, reactor.removeSystemEventTrigger, (b[0], ('xxx',) + b[1][1:]))
Example #7
Source File: test_internet.py From python-for-android with Apache License 2.0 | 5 votes |
def removeTrigger(self, trigger): """ Remove a trigger by its handle from the reactor and from C{self.triggers}. """ reactor.removeSystemEventTrigger(trigger) self.triggers.remove(trigger)
Example #8
Source File: eventloop.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def stop(self): """stop() Stop all services in the region's event-loop. """ if self.handle is not None: handle, self.handle = self.handle, None reactor.removeSystemEventTrigger(handle) return self.services.stopService()
Example #9
Source File: test_internet.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def removeTrigger(self, trigger): reactor.removeSystemEventTrigger(trigger) self.triggers.remove(trigger)
Example #10
Source File: test_internet.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def testTriggerSystemEvent5(self): # make sure the reactor can handle attempts to remove bogus triggers l = [] def _appendToList(l=l): l.append(1) r = reactor b = self.addTrigger("after", "event1", _appendToList) self.removeTrigger(b) if type(b) == types.IntType: bogus = b + 40 self.failUnlessRaises(ValueError, r.removeSystemEventTrigger, bogus) self.failUnlessRaises(TypeError, r.removeSystemEventTrigger, None)
Example #11
Source File: test_internet.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def tearDown(self): for t in self.triggers: try: reactor.removeSystemEventTrigger(t) except: pass
Example #12
Source File: test_internet.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def removeTrigger(self, trigger): reactor.removeSystemEventTrigger(trigger) self.triggers.remove(trigger)
Example #13
Source File: adbapi.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def close(self): """Close all pool connections and shutdown the pool.""" from twisted.internet import reactor if self.shutdownID: reactor.removeSystemEventTrigger(self.shutdownID) self.shutdownID = None if self.startID: reactor.removeSystemEventTrigger(self.startID) self.startID = None self.finalClose()
Example #14
Source File: test_internet.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def tearDown(self): """ Remove all remaining triggers from the reactor. """ while self.triggers: trigger = self.triggers.pop() try: reactor.removeSystemEventTrigger(trigger) except (ValueError, KeyError): pass
Example #15
Source File: test_internet.py From python-for-android with Apache License 2.0 | 5 votes |
def tearDown(self): """ Remove all remaining triggers from the reactor. """ while self.triggers: trigger = self.triggers.pop() try: reactor.removeSystemEventTrigger(trigger) except (ValueError, KeyError): pass
Example #16
Source File: test_internet.py From learn_python3_spider with MIT License | 5 votes |
def removeTrigger(self, trigger): """ Remove a trigger by its handle from the reactor and from C{self.triggers}. """ reactor.removeSystemEventTrigger(trigger) self.triggers.remove(trigger)
Example #17
Source File: test_internet.py From learn_python3_spider with MIT License | 5 votes |
def tearDown(self): """ Remove all remaining triggers from the reactor. """ while self.triggers: trigger = self.triggers.pop() try: reactor.removeSystemEventTrigger(trigger) except (ValueError, KeyError): pass
Example #18
Source File: test_internet.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def removeTrigger(self, trigger): """ Remove a trigger by its handle from the reactor and from C{self.triggers}. """ reactor.removeSystemEventTrigger(trigger) self.triggers.remove(trigger)