I 'm deploying a Python application to a Verdin IMX8MM using the VSC extension and I want to get some user input from the command line as part of the application but the input() function throws the EOFError exception. When I SSH to the host, enter the container and run the application it works fine. Is there a way to get it to work in VSC as well? I think this is because stdin is being redirected to a file instead of the terminal but I can’t figure out if there is a setting to fix it.
When we debug a Python (or C/C++) application with Torizon Extension, the console I/O is processed by the debugger and stdin is not accessible by default, and we don’t redirect it through docker.
Our suggestion is for you to read info from a regular file instead or, if you have a menu or something like this, expose it via socket for the testing.
Thanks Andre, I will take a look at the socket idea. Any suggestions very welcome.
And, please, let us know if you managed to debug it, even using socket.
I did make this work and have written a python class to act as a debug socket. If anyone needs it just let me know and I can share.
That is really interesting!
Can you share with us?
@valter.tx what do you think about it?
If it’s something you can share that would be great to improve usability.
Hi @valter.tx and @andrecurvello.tx,
I have attached here, it should work for Windows or Linux but I have not tried on Windows for a while. It has been working ok for me in debug mode on Torizon. Of course you don’t really need it in release builds as I can just attach to the running container from SSH but it does still work as well.
Usage should just be:
dss = DebugSocket()
The print menu function I pass just prints some text. Socket will redirect stdio for you once someone connects on a raw 65432 port. And will return control when they disconnect. Only remaining todo is to add a timeout to detect a badly behaved disconnection. At the moment it just waits for ever.
Thanks for sharing the files.