Python twisted.internet.defer.setDebugging() Examples
The following are 30
code examples of twisted.internet.defer.setDebugging().
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.defer
, or try the search function
.
Example #1
Source File: test_defer.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_errbackWithNoArgsNoDebug(self): """ C{Deferred.errback()} creates a failure from the current Python exception. When Deferred.debug is not set no globals or locals are captured in that failure. """ defer.setDebugging(False) d = defer.Deferred() l = [] exc = GenericError("Bang") try: raise exc except: d.errback() d.addErrback(l.append) fail = l[0] self.assertEqual(fail.value, exc) localz, globalz = fail.frames[0][-2:] self.assertEqual([], localz) self.assertEqual([], globalz)
Example #2
Source File: test_defer.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_errbackWithNoArgs(self): """ C{Deferred.errback()} creates a failure from the current Python exception. When Deferred.debug is set globals and locals are captured in that failure. """ defer.setDebugging(True) d = defer.Deferred() l = [] exc = GenericError("Bang") try: raise exc except: d.errback() d.addErrback(l.append) fail = l[0] self.assertEqual(fail.value, exc) localz, globalz = fail.frames[0][-2:] self.assertNotEqual([], localz) self.assertNotEqual([], globalz)
Example #3
Source File: test_defer.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_errorInCallbackDoesNotCaptureVars(self): """ An error raised by a callback creates a Failure. The Failure captures locals and globals if and only if C{Deferred.debug} is set. """ d = defer.Deferred() d.callback(None) defer.setDebugging(False) def raiseError(ignored): raise GenericError("Bang") d.addCallback(raiseError) l = [] d.addErrback(l.append) fail = l[0] localz, globalz = fail.frames[0][-2:] self.assertEqual([], localz) self.assertEqual([], globalz)
Example #4
Source File: test_calvin_network.py From calvin-base with Apache License 2.0 | 6 votes |
def test_link_request(self, monkeypatch): #import sys #from twisted.python import log #log.startLogging(sys.stdout) #defer.setDebugging(True) yield self._create_servers(2) # Connect cb, d = create_callback() net1_port = self._get_port(1) node_id = self._get_node_id(1) self._get_network(0).link_request(node_id, callback=cb) b = yield d assert b[1]['status'] assert self._get_network(0).link_get(b[0][0]) self._get_network(0).link_get(b[0][0]).close() disconnect = self._get_network(1)._peer_disconnected.side_effect_ds[0] yield disconnect assert self._get_network(1)._peer_disconnected.call_count == 1 # reason OK assert self._get_network(1)._peer_disconnected.call_args[0][2] == "OK" yield self._stop_servers()
Example #5
Source File: test_defer.py From learn_python3_spider with MIT License | 6 votes |
def test_errorInCallbackDoesNotCaptureVars(self): """ An error raised by a callback creates a Failure. The Failure captures locals and globals if and only if C{Deferred.debug} is set. """ d = defer.Deferred() d.callback(None) defer.setDebugging(False) def raiseError(ignored): raise GenericError("Bang") d.addCallback(raiseError) l = [] d.addErrback(l.append) fail = l[0] localz, globalz = fail.frames[0][-2:] self.assertEqual([], localz) self.assertEqual([], globalz)
Example #6
Source File: test_defer.py From learn_python3_spider with MIT License | 6 votes |
def test_errbackWithNoArgs(self): """ C{Deferred.errback()} creates a failure from the current Python exception. When Deferred.debug is set globals and locals are captured in that failure. """ defer.setDebugging(True) d = defer.Deferred() l = [] exc = GenericError("Bang") try: raise exc except: d.errback() d.addErrback(l.append) fail = l[0] self.assertEqual(fail.value, exc) localz, globalz = fail.frames[0][-2:] self.assertNotEqual([], localz) self.assertNotEqual([], globalz)
Example #7
Source File: test_defer.py From learn_python3_spider with MIT License | 6 votes |
def test_errbackWithNoArgsNoDebug(self): """ C{Deferred.errback()} creates a failure from the current Python exception. When Deferred.debug is not set no globals or locals are captured in that failure. """ defer.setDebugging(False) d = defer.Deferred() l = [] exc = GenericError("Bang") try: raise exc except: d.errback() d.addErrback(l.append) fail = l[0] self.assertEqual(fail.value, exc) localz, globalz = fail.frames[0][-2:] self.assertEqual([], localz) self.assertEqual([], globalz)
Example #8
Source File: test_defer.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def testNoDebugging(self): defer.setDebugging(False) d = defer.Deferred() d.addCallbacks(self._callback, self._errback) self._call_1(d) try: self._call_2(d) except defer.AlreadyCalledError, e: self.failIf(e.args)
Example #9
Source File: test_defer.py From python-for-android with Apache License 2.0 | 5 votes |
def setUp(self): self._deferredWasDebugging = defer.getDebugging() defer.setDebugging(True)
Example #10
Source File: test_defer.py From python-for-android with Apache License 2.0 | 5 votes |
def tearDown(self): defer.setDebugging(self._deferredWasDebugging)
Example #11
Source File: test_defer.py From python-for-android with Apache License 2.0 | 5 votes |
def testNoDebugging(self): defer.setDebugging(False) d = defer.Deferred() d.addCallbacks(self._callback, self._errback) self._call_1(d) try: self._call_2(d) except defer.AlreadyCalledError, e: self.failIf(e.args)
Example #12
Source File: test_defer.py From python-for-android with Apache License 2.0 | 5 votes |
def testSwitchDebugging(self): # Make sure Deferreds can deal with debug state flipping # around randomly. This is covering a particular fixed bug. defer.setDebugging(False) d = defer.Deferred() d.addBoth(lambda ign: None) defer.setDebugging(True) d.callback(None) defer.setDebugging(False) d = defer.Deferred() d.callback(None) defer.setDebugging(True) d.addBoth(lambda ign: None)
Example #13
Source File: app.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def opt_debug(self): """ run the application in the Python Debugger (implies nodaemon), sending SIGUSR2 will drop into debugger """ defer.setDebugging(True) failure.startDebugMode() self['debug'] = True
Example #14
Source File: test_defer.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def setUp(self): self._deferredWasDebugging = defer.getDebugging() defer.setDebugging(True)
Example #15
Source File: test_defer.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def tearDown(self): defer.setDebugging(self._deferredWasDebugging)
Example #16
Source File: test_defer.py From learn_python3_spider with MIT License | 5 votes |
def testNoDebugging(self): defer.setDebugging(False) d = defer.Deferred() d.addCallbacks(self._callback, self._errback) self._call_1(d) try: self._call_2(d) except defer.AlreadyCalledError as e: self.assertFalse(e.args) else: self.fail("second callback failed to raise AlreadyCalledError")
Example #17
Source File: test_defer.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def testSwitchDebugging(self): # Make sure Deferreds can deal with debug state flipping # around randomly. This is covering a particular fixed bug. defer.setDebugging(False) d = defer.Deferred() d.addBoth(lambda ign: None) defer.setDebugging(True) d.callback(None) defer.setDebugging(False) d = defer.Deferred() d.callback(None) defer.setDebugging(True) d.addBoth(lambda ign: None)
Example #18
Source File: test_calvin.py From calvin-base with Apache License 2.0 | 5 votes |
def testStartNode(self): """Testing starting node""" #import sys #from twisted.python import log #from twisted.internet import defer #log.startLogging(sys.stdout) #defer.setDebugging(True) assert request_handler.get_node(self.rt1, self.rt1.id)['uris'] == self.rt1.uris
Example #19
Source File: test_calvin.py From calvin-base with Apache License 2.0 | 5 votes |
def testRemoteOneActor(self): """Testing remote port""" from twisted.python import log from twisted.internet import defer import sys defer.setDebugging(True) log.startLogging(sys.stdout) rt = self.rt1 peer = self.rt2 snk = request_handler.new_actor_wargs(rt, 'test.Sink', 'snk', store_tokens=1, quiet=1) csum = request_handler.new_actor(peer, 'std.Sum', 'sum') src = request_handler.new_actor(rt, 'std.CountTimer', 'src') request_handler.connect(rt, snk, 'token', peer.id, csum, 'integer') request_handler.connect(peer, csum, 'integer', rt.id, src, 'integer') # Wait for some tokens actual = wait_for_tokens(rt, snk, 10) request_handler.disconnect(rt, src) # Fetch sent expected = expected_tokens(rt, src, 'sum') self.assert_lists_equal(expected, actual) request_handler.delete_actor(rt, snk) request_handler.delete_actor(peer, csum) request_handler.delete_actor(rt, src)
Example #20
Source File: test_secure_calvin.py From calvin-base with Apache License 2.0 | 5 votes |
def testStartNode(self): """Testing starting node""" #import sys #from twisted.python import log #from twisted.internet import defer #log.startLogging(sys.stdout) #defer.setDebugging(True) assert request_handler.get_node(rt1, rt1.id)['uris'] == rt1.uris #@pytest.mark.essential
Example #21
Source File: test_secure_calvin.py From calvin-base with Apache License 2.0 | 5 votes |
def testRemoteOneActor(self): """Testing remote port""" from twisted.python import log from twisted.internet import defer import sys defer.setDebugging(True) log.startLogging(sys.stdout) rt = runtimes[1]["RT"] peer = runtimes[2]["RT"] request_handler.set_credentials({"user": "user0", "password": "pass0"}) snk = request_handler.new_actor_wargs(rt, 'test.Sink', 'snk', store_tokens=1, quiet=1) csum = request_handler.new_actor(peer, 'std.Sum', 'sum') src = request_handler.new_actor(rt, 'std.CountTimer', 'src') request_handler.connect(rt, snk, 'token', peer.id, csum, 'integer') request_handler.connect(peer, csum, 'integer', rt.id, src, 'integer') # Wait for some tokens actual = wait_for_tokens(rt, snk, 10) request_handler.disconnect(rt, src) # Fetch sent expected = expected_tokens(rt, src, 'sum') assert_lists_equal(expected, actual) request_handler.delete_actor(rt, snk) request_handler.delete_actor(peer, csum) request_handler.delete_actor(rt, src)
Example #22
Source File: test_task_runner.py From voltha with Apache License 2.0 | 5 votes |
def setUp(self): # defer.setDebugging(True) self.runner = TaskRunner(DEVICE_ID)
Example #23
Source File: app.py From python-for-android with Apache License 2.0 | 5 votes |
def opt_debug(self): """ run the application in the Python Debugger (implies nodaemon), sending SIGUSR2 will drop into debugger """ defer.setDebugging(True) failure.startDebugMode() self['debug'] = True
Example #24
Source File: trial.py From learn_python3_spider with MIT License | 5 votes |
def _initialDebugSetup(config): # do this part of debug setup first for easy debugging of import failures if config['debug']: failure.startDebugMode() if config['debug'] or config['debug-stacktraces']: defer.setDebugging(True)
Example #25
Source File: test_defer.py From learn_python3_spider with MIT License | 5 votes |
def testSwitchDebugging(self): # Make sure Deferreds can deal with debug state flipping # around randomly. This is covering a particular fixed bug. defer.setDebugging(False) d = defer.Deferred() d.addBoth(lambda ign: None) defer.setDebugging(True) d.callback(None) defer.setDebugging(False) d = defer.Deferred() d.callback(None) defer.setDebugging(True) d.addBoth(lambda ign: None)
Example #26
Source File: __init__.py From afkak with Apache License 2.0 | 5 votes |
def _twisted_debug(): """ When the ``AFKAK_TWISTED_DEBUG`` environment variable is set, enable debugging of deferreds and delayed calls. """ if os.environ.get('AFKAK_TWISTED_DEBUG'): from twisted.internet import defer from twisted.internet.base import DelayedCall defer.setDebugging(True) DelayedCall.debug = True
Example #27
Source File: test_defer.py From learn_python3_spider with MIT License | 5 votes |
def tearDown(self): defer.setDebugging(self._deferredWasDebugging)
Example #28
Source File: test_defer.py From learn_python3_spider with MIT License | 5 votes |
def setUp(self): self._deferredWasDebugging = defer.getDebugging() defer.setDebugging(True)
Example #29
Source File: test_defer.py From learn_python3_spider with MIT License | 5 votes |
def setUp(self): self.callbackResults = None self.errbackResults = None self.callback2Results = None # Restore the debug flag to its original state when done. self.addCleanup(defer.setDebugging, defer.getDebugging())
Example #30
Source File: app.py From learn_python3_spider with MIT License | 5 votes |
def opt_debug(self): """ Run the application in the Python Debugger (implies nodaemon), sending SIGUSR2 will drop into debugger """ defer.setDebugging(True) failure.startDebugMode() self['debug'] = True