diff options
author | Thais Siqueira <thais.siqueira@gmail.com> | 2016-08-26 13:42:47 -0300 |
---|---|---|
committer | Thais Siqueira <thais.siqueira@gmail.com> | 2016-08-26 13:42:47 -0300 |
commit | 2d4d7d627e85c249f3ec0f16d58159647b99e779 (patch) | |
tree | f6474a244862d2370351dcaf9febe9f2c1a1aef8 /service/test/reactor | |
parent | 8e86631f40ae81826b5a6dfa56d38a4c4cbbaaad (diff) |
Revert "fixing twisted patch"
This reverts commit 480e7d3bd48f2a7c23a76843750daaa03f2b12b3.
Diffstat (limited to 'service/test/reactor')
-rw-r--r-- | service/test/reactor/defer.patch | 130 |
1 files changed, 51 insertions, 79 deletions
diff --git a/service/test/reactor/defer.patch b/service/test/reactor/defer.patch index fdd5a251..296112f4 100644 --- a/service/test/reactor/defer.patch +++ b/service/test/reactor/defer.patch @@ -1,79 +1,51 @@ -diff --git a/lib/python2.7/site-packages/twisted/internet/defer.py b/lib/python2.7/site-packages/twisted/internet/defer.py -index fe9f0a0..5c428d3 100644 ---- a/lib/python2.7/site-packages/twisted/internet/defer.py -+++ b/lib/python2.7/site-packages/twisted/internet/defer.py -@@ -31,6 +31,19 @@ from twisted.logger import Logger - from twisted.python.deprecate import warnAboutFunction, deprecated - from twisted.python.versions import Version - -+from datetime import datetime -+ -+class Clock(): -+ def __init__(self, label): -+ self.start = datetime.now() -+ self.label = label -+ -+ def stop(self, callback_type): -+ end = datetime.now() -+ total = (end - self.start).total_seconds() -+ if total > 0.001: -+ print('{:.5f} EXECUTING {}: {}'.format(total, callback_type, self.label)) -+ - log = Logger() - - -@@ -192,7 +205,20 @@ def getDebugging(): - _NO_RESULT = object() - _CONTINUE = object() - -- -+import threading -+import inspect -+def identifyItem(i): -+ if i is None: -+ return "(None)" -+ else: -+ if inspect.isbuiltin(i): -+ return str(i) -+ else: -+ if 'gotResult' == i.__name__: -+ return False -+ f = inspect.getsourcefile(i) -+ ln = inspect.getsourcelines(i)[1] -+ return "%s (%s:%d)" % (str(i), f, ln) - - class Deferred: - """ -@@ -585,7 +611,17 @@ class Deferred: - try: - current._runningCallbacks = True - try: -- current.result = callback(current.result, *args, **kw) -+ currentItem = identifyItem(callback) -+ currentThreadId = threading.current_thread().ident -+ -+ if currentItem: -+ clock = Clock("%s in thread %d" % (currentItem, currentThreadId)) -+ try: -+ current.result = callback(current.result, *args, **kw) -+ finally: -+ if currentItem: -+ clock.stop('deferred') -+ - if current.result is current: - warnAboutFunction( - callback, -@@ -1271,7 +1307,12 @@ def inlineCallbacks(f): - raise TypeError( - "inlineCallbacks requires %r to produce a generator; " - "instead got %r" % (f, gen)) -- return _inlineCallbacks(None, gen, Deferred()) -+ currentThreadId = threading.current_thread().ident -+ c = Clock("%s in thread %d" % (f, currentThreadId)) -+ result = _inlineCallbacks(None, gen, Deferred()) -+ c.stop('inlineCallback') -+ return result -+# return _inlineCallbacks(None, gen, Deferred()) - return unwindGenerator - - +33a34,46 +> from datetime import datetime +> +> class Clock(): +> def __init__(self, label): +> self.start = datetime.now() +> self.label = label +> +> def stop(self, callback_type): +> end = datetime.now() +> total = (end - self.start).total_seconds() +> if total > 0.1: +> print('EXECUTING {}: {} {:.5f}'.format(callback_type, self.label, total)) +> +195c208,221 +< +--- +> import threading +> import inspect +> def identifyItem(i): +> if i is None: +> return "(None)" +> else: +> if inspect.isbuiltin(i): +> return str(i) +> else: +> if 'gotResult' == i.__name__: +> return False +> f = inspect.getsourcefile(i) +> ln = inspect.getsourcelines(i)[1] +> return "%s (%s:%d)" % (str(i), f, ln) +588c614,624 +< current.result = callback(current.result, *args, **kw) +--- +> currentItem = identifyItem(callback) +> currentThreadId = threading.current_thread().ident +> +> if currentItem: +> clock = Clock("%s in thread %d" % (currentItem, currentThreadId)) +> try: +> current.result = callback(current.result, *args, **kw) +> finally: +> if currentItem: +> clock.stop('deferred') +> +1123a1160,1161 +> currentThreadId = threading.current_thread().ident +> c = Clock("%s in thread %d" % (str(g.gi_code), currentThreadId)) +1175a1214,1215 +> finally: +> c.stop('inlineCallback') |