Setting PYTHONUNBUFFERED to 1 can cause remote execution to fail

Answered

We had PYTHONUNBUFFERED set by default for all our remote execution/debugging. At some point things started getting flaky. Sometimes remote commands would execute. Sometimes they would quietly do nothing at all with no errors. It was very random. I finally identified the problem digging through the console output. 

Sometimes you'd see a message about an unexpected string in the output. All the time it failed there would be a failure to connect to the console.

When the helper routine fires up, it spits out two socket numbers which PyCharm uses to connect to the process.

However, there is also a print line in pydef_run_in_console.py that prints "Running name-of-program". Those are running in different threads/processes in the same console. If the output is not buffered, then those two can step on each other.

Instead of:

Running tools/report_mismappings.py
36058

You get things like:

36058Running tools/report_mismappings.py

The workaround is to turn off unbuffered output (setting it to 0 doesn't seem to work, I finally just removed the setting). But it seems to me there ought to be changes that IntelliJ could make to fix this. It never used to be a problem.

0
2 comments

Actually, I've now seen the same behavior even with I/O buffered. The only solution may be to get rid of the print statement in pydef_run_in_console.py

0

Hello! Thank you for the report. I've created https://youtrack.jetbrains.com/issue/PY-27315 in Pycharm bug tracker, please follow it for updates. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

0

Please sign in to leave a comment.