vscode-code-runner: Incomplete output displayed and [Done] exited with code=null

When running a program with lots of console output, I’m getting a “[Done] exited with code=null in 0.0XX seconds” before all of the output has actually been written to the console.

Below is a simple Python3 example to reproduce the problem. Each time the code is run, the console output will enumerate to a different count value before it stops with the code=null exit code.

for count in range(100000):
    print(count)

The output window displays…

...
37345
37346
37347
37348
37349
37
[Done] exited with code=null in 0.044 seconds

If I run the same example in the Visual Studio Code terminal window, the full expected output is displayed every time.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I’m not a Javascript/NodeJS programmer, but I did some reading of the code in this extension, as well as the NodeJS API, and think I may have come across something interesting.

I see that the exec() fucntion of child_process is being used in the executeCommandInOutputChannel() function in the codeManager.ts file. I’m understanding that exec() spawns a shell and executes the command within that shell, buffering any generated output. There is a maxBuffer option that is documented as:

maxBuffer <number> : Largest amount of data in bytes allowed on stdout or stderr. (Default: 200*1024) If exceeded, the child process is terminated. See caveat at maxBuffer and Unicode.

https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

It looks as though the spawn() function should be used instead, since the data is streamed as standard IO objects – not buffered strings.

For quick turnaround, you could use below setting (File->Preference->Settings) to run code in Integrated Terminal:

{
    "code-runner.runInTerminal": true
}

Also, you may try below setting to run:

{
    "code-runner.executorMap.python": "python -u"
}

Are those options working for you?

Hello, can anybody help me please. When i’m running terminal, i 've got very long details in terminal. How can i remove it, just to have the result of code thank you in advance
terminal3

wanna have like this one terminal2