Python-process-console

Матеріал з Wiki Welard
Версія від 20:33, 6 березня 2015, створена WikiSysop (обговорення | внесок) (Створена сторінка: '''python: is it possible to attach a console into a running process''' [http://stackoverflow.com/questions/4163964/python-is-it-possible-to-attach-a-console-in...)
(різн.) ← Попередня версія | Поточна версія (різн.) | Новіша версія → (різн.)
Перейти до навігації Перейти до пошуку

python: is it possible to attach a console into a running process [1]

Debugging a running python process by interrupting and providing an interactive prompt (Python recipe) [2]

Another implementation of roughly the same concept is provided by rconsole. From the documentation:

rconsole is a remote Python console with auto completion, which can be used to inspect and modify the namespace of a running script.

To invoke in a script do:

from rfoo.utils import rconsole
rconsole.spawn_server()

To attach from a shell do:

$ rconsole

Security note: The rconsole listener started with spawn_server() will accept any local connection and may therefore be insecure to use in shared hosting or similar environments!