Interactive Python interpreter that accepts remote connections.
This Python package allows you to embed a REPL into your Python programs.
It was initially conceived to allow for remote access to long running processes such as web servers, but was adapted to work with long running GUI processes that have a Python API (e.g. Maya and Nuke).
Read the docs, and good luck!