In Python, the following code snippet will open an interactive shell after execution.
import code; code.interact(local = locals())
This has proven extremely useful for debugging in a fairly small amount of code that is poorly documented. You can use the shell to navigate the in-program environment and find out what happens even without a debugger. So far so good.
Now the problem.
The software I use (which, by the way, is written in Django) uses some kind of scheduling mechanism, which then talks about another Python process that I have no control over other than editing its code. I have no input to it, except for the variables that I send for processing.
However, I do not know how the code works, since the documentation is very poor, so I wanted to use the code.interact method to understand what was going on.
But this process starts somewhere in the background using special planning software, so the thread does not go from the Django application to the parts I want to learn. Instead, a signal and an object are sent, which are then triggered later, at any time (somewhere between 10-200 ms) in a completely different process. When a signal and an object are received, stdin / stdout is completely absent.
So I decided that instead of using stdin / stdout to communicate with code.interact I could use a file descriptor or a Unix socket by specifying the readfunc parameter. I tried this with open() with a file and socket, but to no avail.
Now I'm trying to get this to work only from the Django process itself, so even the scheduling problem is out of the question, and although the interactive shell really starts, it shuts down immediately, not accepting the command file as content, and also not the Unix socket with which related Python commands.
In short; Is it possible to interact with the interactive shell called by code.interact other ways than stdin / stdout? If so, how?
Thanks in advance.