Python threading.settrace() Examples

The following are code examples for showing how to use threading.settrace(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: NiujiaoDebugger   Author: MrSrc   File: test_threading.py    GNU General Public License v3.0 6 votes vote down vote up
def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        assert_python_ok("-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print('program blocked; aborting')
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            """) 
Example 2
Project: Blockly-rduino-communication   Author: technologiescollege   File: test_threading.py    GNU General Public License v3.0 6 votes vote down vote up
def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        assert_python_ok("-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print('program blocked; aborting')
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            """) 
Example 3
Project: cqp-sdk-for-py37-native   Author: crud-boy   File: trace.py    GNU General Public License v2.0 6 votes vote down vote up
def runfunc(*args, **kw):
        if len(args) >= 2:
            self, func, *args = args
        elif not args:
            raise TypeError("descriptor 'runfunc' of 'Trace' object "
                            "needs an argument")
        elif 'func' in kw:
            func = kw.pop('func')
            self, *args = args
        else:
            raise TypeError('runfunc expected at least 1 positional argument, '
                            'got %d' % (len(args)-1))

        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 4
Project: cqp-sdk-for-py37-native   Author: crud-boy   File: test_threading.py    GNU General Public License v2.0 6 votes vote down vote up
def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        assert_python_ok("-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print('program blocked; aborting')
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            """) 
Example 5
Project: pyblish-win   Author: pyblish   File: trace.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 6
Project: pyblish-win   Author: pyblish   File: trace.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 7
Project: pyblish-win   Author: pyblish   File: trace.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 8
Project: pyblish-win   Author: pyblish   File: trace.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 9
Project: pyblish-win   Author: pyblish   File: test_threading.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        p = subprocess.Popen([sys.executable, "-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print 'program blocked; aborting'
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            """],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        self.addCleanup(p.stdout.close)
        self.addCleanup(p.stderr.close)
        stdout, stderr = p.communicate()
        rc = p.returncode
        self.assertFalse(rc == 2, "interpreted was blocked")
        self.assertTrue(rc == 0,
                        "Unexpected error: " + repr(stderr)) 
Example 10
Project: flasky   Author: RoseOu   File: collector.py    MIT License 5 votes vote down vote up
def start(self):
        """Start this Tracer.

        Return a Python function suitable for use with sys.settrace().

        """
        self.thread = threading.currentThread()
        sys.settrace(self._trace)
        return self._trace 
Example 11
Project: flasky   Author: RoseOu   File: collector.py    MIT License 5 votes vote down vote up
def stop(self):
        """Stop this Tracer."""
        self.stopped = True
        if self.thread != threading.currentThread():
            # Called on a different thread than started us: we can't unhook
            # ourseves, but we've set the flag that we should stop, so we won't
            # do any more tracing.
            return

        if hasattr(sys, "gettrace") and self.warn:
            if sys.gettrace() != self._trace:
                msg = "Trace function changed, measurement is likely wrong: %r"
                self.warn(msg % (sys.gettrace(),))
        #print("Stopping tracer on %s" % threading.current_thread().ident)
        sys.settrace(None) 
Example 12
Project: flasky   Author: RoseOu   File: collector.py    MIT License 5 votes vote down vote up
def _installation_trace(self, frame_unused, event_unused, arg_unused):
        """Called on new threads, installs the real tracer."""
        # Remove ourselves as the trace function
        sys.settrace(None)
        # Install the real tracer.
        fn = self._start_tracer()
        # Invoke the real trace function with the current event, to be sure
        # not to lose an event.
        if fn:
            fn = fn(frame_unused, event_unused, arg_unused)
        # Return the new trace function to continue tracing in this scope.
        return fn 
Example 13
Project: flasky   Author: RoseOu   File: collector.py    MIT License 5 votes vote down vote up
def start(self):
        """Start collecting trace information."""
        if self._collectors:
            self._collectors[-1].pause()
        self._collectors.append(self)
        #print("Started: %r" % self._collectors, file=sys.stderr)

        # Check to see whether we had a fullcoverage tracer installed.
        traces0 = []
        if hasattr(sys, "gettrace"):
            fn0 = sys.gettrace()
            if fn0:
                tracer0 = getattr(fn0, '__self__', None)
                if tracer0:
                    traces0 = getattr(tracer0, 'traces', [])

        # Install the tracer on this thread.
        fn = self._start_tracer()

        for args in traces0:
            (frame, event, arg), lineno = args
            try:
                fn(frame, event, arg, lineno=lineno)
            except TypeError:
                raise Exception(
                    "fullcoverage must be run with the C trace function."
                )

        # Install our installation tracer in threading, to jump start other
        # threads.
        threading.settrace(self._installation_trace) 
Example 14
Project: flasky   Author: RoseOu   File: collector.py    MIT License 5 votes vote down vote up
def pause(self):
        """Pause tracing, but be prepared to `resume`."""
        for tracer in self.tracers:
            tracer.stop()
            stats = tracer.get_stats()
            if stats:
                print("\nCoverage.py tracer stats:")
                for k in sorted(stats.keys()):
                    print("%16s: %s" % (k, stats[k]))
        threading.settrace(None) 
Example 15
Project: NiujiaoDebugger   Author: MrSrc   File: trace.py    GNU General Public License v3.0 5 votes vote down vote up
def runctx(self, cmd, globals=None, locals=None):
        if globals is None: globals = {}
        if locals is None: locals = {}
        if not self.donothing:
            threading.settrace(self.globaltrace)
            sys.settrace(self.globaltrace)
        try:
            exec(cmd, globals, locals)
        finally:
            if not self.donothing:
                sys.settrace(None)
                threading.settrace(None) 
Example 16
Project: NiujiaoDebugger   Author: MrSrc   File: trace.py    GNU General Public License v3.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 17
Project: NiujiaoDebugger   Author: MrSrc   File: test_threading.py    GNU General Public License v3.0 5 votes vote down vote up
def test_frame_tstate_tracing(self):
        # Issue #14432: Crash when a generator is created in a C thread that is
        # destroyed while the generator is still used. The issue was that a
        # generator contains a frame, and the frame kept a reference to the
        # Python state of the destroyed C thread. The crash occurs when a trace
        # function is setup.

        def noop_trace(frame, event, arg):
            # no operation
            return noop_trace

        def generator():
            while 1:
                yield "generator"

        def callback():
            if callback.gen is None:
                callback.gen = generator()
            return next(callback.gen)
        callback.gen = None

        old_trace = sys.gettrace()
        sys.settrace(noop_trace)
        try:
            # Install a trace function
            threading.settrace(noop_trace)

            # Create a generator in a C thread which exits after the call
            import _testcapi
            _testcapi.call_in_temporary_c_thread(callback)

            # Call the generator in a different Python thread, check that the
            # generator didn't keep a reference to the destroyed thread state
            for test in range(3):
                # The trace function is still called here
                callback()
        finally:
            sys.settrace(old_trace) 
Example 18
Project: ironpython2   Author: IronLanguages   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 19
Project: ironpython2   Author: IronLanguages   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 20
Project: ironpython2   Author: IronLanguages   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 21
Project: ironpython2   Author: IronLanguages   File: trace.py    Apache License 2.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 22
Project: ironpython2   Author: IronLanguages   File: test_threading.py    Apache License 2.0 5 votes vote down vote up
def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        p = subprocess.Popen([sys.executable, "-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print 'program blocked; aborting'
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            """],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        self.addCleanup(p.stdout.close)
        self.addCleanup(p.stderr.close)
        stdout, stderr = p.communicate()
        rc = p.returncode
        self.assertFalse(rc == 2, "interpreted was blocked")
        self.assertTrue(rc == 0,
                        "Unexpected error: " + repr(stderr)) 
Example 23
Project: open-recipe   Author: dspray95   File: app.py    The Unlicense 5 votes vote down vote up
def opt_spew(self):
        """
        Print an insanely verbose log of everything that happens.
        Useful when debugging freezes or locks in complex code.
        """
        sys.settrace(util.spewer)
        try:
            import threading
        except ImportError:
            return
        threading.settrace(util.spewer) 
Example 24
Project: Blockly-rduino-communication   Author: technologiescollege   File: trace.py    GNU General Public License v3.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 25
Project: Blockly-rduino-communication   Author: technologiescollege   File: trace.py    GNU General Public License v3.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 26
Project: Blockly-rduino-communication   Author: technologiescollege   File: trace.py    GNU General Public License v3.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 27
Project: Blockly-rduino-communication   Author: technologiescollege   File: trace.py    GNU General Public License v3.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 28
Project: Comparative-Annotation-Toolkit   Author: ComparativeGenomicsToolkit   File: trace.py    Apache License 2.0 5 votes vote down vote up
def enable(self):
        """enable logging on all threads."""
        assert(self.fh is not None)
        sys.settrace(self.__callback)
        threading.settrace(self.__callback) 
Example 29
Project: Comparative-Annotation-Toolkit   Author: ComparativeGenomicsToolkit   File: trace.py    Apache License 2.0 5 votes vote down vote up
def disable(self):
        """disable logging on all threads."""
        sys.settrace(None)
        threading.settrace(None) 
Example 30
Project: IronHydra   Author: microdee   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 31
Project: IronHydra   Author: microdee   File: trace.py    MIT License 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 32
Project: IronHydra   Author: microdee   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 33
Project: IronHydra   Author: microdee   File: trace.py    MIT License 5 votes vote down vote up
def run(self, cmd):
        import __main__
        dict = __main__.__dict__
        if not self.donothing:
            threading.settrace(self.globaltrace)
            sys.settrace(self.globaltrace)
        try:
            exec cmd in dict, dict
        finally:
            if not self.donothing:
                sys.settrace(None)
                threading.settrace(None) 
Example 34
Project: IronHydra   Author: microdee   File: trace.py    MIT License 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 35
Project: cqp-sdk-for-py37-native   Author: crud-boy   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def runctx(self, cmd, globals=None, locals=None):
        if globals is None: globals = {}
        if locals is None: locals = {}
        if not self.donothing:
            threading.settrace(self.globaltrace)
            sys.settrace(self.globaltrace)
        try:
            exec(cmd, globals, locals)
        finally:
            if not self.donothing:
                sys.settrace(None)
                threading.settrace(None) 
Example 36
Project: cqp-sdk-for-py37-native   Author: crud-boy   File: test_threading.py    GNU General Public License v2.0 5 votes vote down vote up
def test_frame_tstate_tracing(self):
        # Issue #14432: Crash when a generator is created in a C thread that is
        # destroyed while the generator is still used. The issue was that a
        # generator contains a frame, and the frame kept a reference to the
        # Python state of the destroyed C thread. The crash occurs when a trace
        # function is setup.

        def noop_trace(frame, event, arg):
            # no operation
            return noop_trace

        def generator():
            while 1:
                yield "generator"

        def callback():
            if callback.gen is None:
                callback.gen = generator()
            return next(callback.gen)
        callback.gen = None

        old_trace = sys.gettrace()
        sys.settrace(noop_trace)
        try:
            # Install a trace function
            threading.settrace(noop_trace)

            # Create a generator in a C thread which exits after the call
            import _testcapi
            _testcapi.call_in_temporary_c_thread(callback)

            # Call the generator in a different Python thread, check that the
            # generator didn't keep a reference to the destroyed thread state
            for test in range(3):
                # The trace function is still called here
                callback()
        finally:
            sys.settrace(old_trace) 
Example 37
Project: aws-lambda-runtime-pypy   Author: uscheller   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 38
Project: aws-lambda-runtime-pypy   Author: uscheller   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 39
Project: aws-lambda-runtime-pypy   Author: uscheller   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 40
Project: aws-lambda-runtime-pypy   Author: uscheller   File: trace.py    Apache License 2.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 41
Project: Computable   Author: ktraunmueller   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 42
Project: Computable   Author: ktraunmueller   File: trace.py    MIT License 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 43
Project: Computable   Author: ktraunmueller   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 44
Project: Computable   Author: ktraunmueller   File: trace.py    MIT License 5 votes vote down vote up
def run(self, cmd):
        import __main__
        dict = __main__.__dict__
        if not self.donothing:
            threading.settrace(self.globaltrace)
            sys.settrace(self.globaltrace)
        try:
            exec cmd in dict, dict
        finally:
            if not self.donothing:
                sys.settrace(None)
                threading.settrace(None) 
Example 45
Project: Computable   Author: ktraunmueller   File: trace.py    MIT License 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 46
Project: oss-ftp   Author: aliyun   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 47
Project: oss-ftp   Author: aliyun   File: trace.py    MIT License 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 48
Project: oss-ftp   Author: aliyun   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 49
Project: oss-ftp   Author: aliyun   File: trace.py    MIT License 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 50
Project: oss-ftp   Author: aliyun   File: test_threading.py    MIT License 5 votes vote down vote up
def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        p = subprocess.Popen([sys.executable, "-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                time.sleep(2)
                print 'program blocked; aborting'
                os._exit(2)
            t = threading.Thread(target=killer)
            t.daemon = True
            t.start()

            # This is the trace function
            def func(frame, event, arg):
                threading.current_thread()
                return func

            sys.settrace(func)
            """],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        self.addCleanup(p.stdout.close)
        self.addCleanup(p.stderr.close)
        stdout, stderr = p.communicate()
        rc = p.returncode
        self.assertFalse(rc == 2, "interpreted was blocked")
        self.assertTrue(rc == 0,
                        "Unexpected error: " + repr(stderr)) 
Example 51
Project: Safejumper-for-Desktop   Author: proxysh   File: app.py    GNU General Public License v2.0 5 votes vote down vote up
def opt_spew(self):
        """
        Print an insanely verbose log of everything that happens.
        Useful when debugging freezes or locks in complex code.
        """
        sys.settrace(util.spewer)
        try:
            import threading
        except ImportError:
            return
        threading.settrace(util.spewer) 
Example 52
Project: setup   Author: mindbender-studio   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 53
Project: setup   Author: mindbender-studio   File: trace.py    MIT License 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 54
Project: setup   Author: mindbender-studio   File: trace.py    MIT License 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 55
Project: setup   Author: mindbender-studio   File: trace.py    MIT License 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 56
Project: webserver   Author: cxsjclassroom   File: utils.py    MIT License 5 votes vote down vote up
def start(self):
		if hasattr(signal, 'SIGALRM') and threading.currentThread().getName() == 'MainThread':
			def handler(signum, frame):
				raise RuntimeError(self.error)
			signal.signal(signal.SIGALRM, handler)
			signal.alarm(self.timeout)
		else:
			def handler(frame, event, arg):
				raise RuntimeError(self.error)

			def set_trace_for_frame_and_parents(frame, trace_func):
				# Note: this only really works if there's a tracing function set in this
				# thread (i.e.: sys.settrace or threading.settrace must have set the
				# function before)
				while frame:
					if frame.f_trace is None:
						frame.f_trace = trace_func
					frame = frame.f_back
				del frame

			def interrupt(thread):
				for thread_id, frame in sys._current_frames().items():
					if thread_id == thread.ident:
						set_trace_for_frame_and_parents(frame, handler)

			sys.settrace(lambda frame, event, arg: None)
			self.timer is not None and self.timer.cancel()
			self.timer = threading.Timer(self.timeout, interrupt, (threading.currentThread(), ))
			self.timer.start() 
Example 57
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 58
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 59
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 60
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 61
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 62
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 63
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 64
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 65
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 66
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 67
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 68
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _settrace(func):
        threading.settrace(func)
        sys.settrace(func) 
Example 69
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 70
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 71
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None) 
Example 72
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)
        threading.settrace(None) 
Example 73
Project: godot-zeronet-plugin   Author: zam-org   File: trace.py    GNU General Public License v2.0 5 votes vote down vote up
def runfunc(self, func, *args, **kw):
        result = None
        if not self.donothing:
            sys.settrace(self.globaltrace)
        try:
            result = func(*args, **kw)
        finally:
            if not self.donothing:
                sys.settrace(None)
        return result 
Example 74
Project: pyFileFixity   Author: lrq3000   File: pprofile.py    MIT License 5 votes vote down vote up
def enable(self):
        """
        Enable profiling.
        """
        if self.enabled_start:
            warn('Duplicate "enable" call')
        else:
            self._enable()
            sys.settrace(self._global_trace) 
Example 75
Project: pyFileFixity   Author: lrq3000   File: pprofile.py    MIT License 5 votes vote down vote up
def disable(self, threads=True):
        """
        Disable profiling.
        """
        if self.enabled_start:
            sys.settrace(None)
            self._disable()
        else:
            warn('Duplicate "disable" call') 
Example 76
Project: pyFileFixity   Author: lrq3000   File: pprofile.py    MIT License 5 votes vote down vote up
def _enable(self):
        self._local_trace = self._local_trace_backup
        threading.settrace(self._global_trace)
        super(ThreadProfile, self)._enable() 
Example 77
Project: pyFileFixity   Author: lrq3000   File: pprofile.py    MIT License 5 votes vote down vote up
def _disable(self):
        super(ThreadProfile, self)._disable()
        threading.settrace(None)
        self._local_trace = None 
Example 78
Project: weibo_twitter_earnings_analysis   Author: lynings   File: app.py    Apache License 2.0 5 votes vote down vote up
def opt_spew(self):
        """
        Print an insanely verbose log of everything that happens.
        Useful when debugging freezes or locks in complex code.
        """
        sys.settrace(util.spewer)
        try:
            import threading
        except ImportError:
            return
        threading.settrace(util.spewer) 
Example 79
Project: learn_python3_spider   Author: wistbean   File: app.py    MIT License 5 votes vote down vote up
def opt_spew(self):
        """
        Print an insanely verbose log of everything that happens.
        Useful when debugging freezes or locks in complex code.
        """
        sys.settrace(util.spewer)
        try:
            import threading
        except ImportError:
            return
        threading.settrace(util.spewer) 
Example 80
Project: KalutClient   Author: TwoUnderscorez   File: trace.py    Apache License 2.0 5 votes vote down vote up
def _unsettrace():
        sys.settrace(None)