Debian Codegraph @

doc/source/modules/backdoor.rst

raw
1 :mod:`backdoor` -- Python interactive interpreter within a running process
2 ===============================================================================
3
4 The backdoor module is convenient for inspecting the state of a long-running process. It supplies the normal Python interactive interpreter in a way that does not block the normal operation of the application. This can be useful for debugging, performance tuning, or simply learning about how things behave in situ.
5
6 In the application, spawn a greenthread running backdoor_server on a listening socket::
7
8 eventlet.spawn(backdoor.backdoor_server, eventlet.listen(('localhost', 3000)), locals())
9
10 When this is running, the backdoor is accessible via telnet to the specified port.
11
12 .. code-block:: sh
13
14 $ telnet localhost 3000
15 (python version, build info)
16 Type "help", "copyright", "credits" or "license" for more information.
17 >>> import myapp
18 >>> dir(myapp)
19 ['__all__', '__doc__', '__name__', 'myfunc']
20 >>>
21
22 The backdoor cooperatively yields to the rest of the application between commands, so on a running server continuously serving requests, you can observe the internal state changing between interpreter commands.
23
24 .. automodule:: eventlet.backdoor
25 :members: