Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python multithreading print error with the integrated terminal #40199

Closed
Meano opened this issue Dec 14, 2017 · 11 comments
Closed

Python multithreading print error with the integrated terminal #40199

Meano opened this issue Dec 14, 2017 · 11 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) terminal Integrated terminal issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) windows VS Code on Windows issues
Milestone

Comments

@Meano
Copy link

Meano commented Dec 14, 2017

  • VSCode Version: Code 1.18.1 (929bacb, 2017-11-16T18:32:36.023Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions:
Extension Author (truncated) Version
code-gnu-global aus 0.2.2
python ms- 0.8.0
cpptools ms- 0.14.4

Steps to Reproduce:

  1. create python script:
from multiprocessing import Pool, cpu_count
import traceback
import sys

def printfunc(msg):
    for i in range(20):
        print "TEST "+ str(msg) +" Count:" + str(i)
    return 0

if __name__ == "__main__":
    try:
        testlist = list(range(1000))
        pool_size = cpu_count()
        pool = Pool(processes=pool_size)
        print "Pool Size:", pool_size
        pool.map(printfunc, testlist)
        pool.close()
        pool.join()
    except Exception,e:
        pool.terminate()
        traceback.print_exc()
        sys.exit(1)
  1. execute the script in integrated terminal will print error message like:

tim 20171214160626

  1. but the script has no errors execute in external terminal (cmd or powershell)

Reproduces without extensions: Yes

@vscodebot vscodebot bot added the terminal Integrated terminal issues label Dec 14, 2017
@Tyriar
Copy link
Member

Tyriar commented Dec 14, 2017

@ivankravets looks like this is the same as platformio/platformio-vscode-ide#61?

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Dec 14, 2017
@Tyriar Tyriar added this to the Backlog milestone Dec 14, 2017
@ivankravets
Copy link

@Tyriar Yes, the same. In our case, the problem is linked with urllib2 library. However, the root of a problem is the same IOError: [Errno 0] Error.

This is a very specific issue. I can't reproduce it on my Windows VMs :(

@Meano
Copy link
Author

Meano commented Dec 15, 2017

@ivankravets I've tested it in windows7 and the issue can't be reproduced. It seems to be related to the OS version. And the problem may happened after I update to Windows 10 1703.

@ivankravets
Copy link

@Meano does Python's socket work for you? Could you try this script

from urllib2 import urlopen

url = "http://dl.platformio.org/packages/toolchain-xtensa-windows-1.40802.0.tar.gz"

r = urlopen(url)
i = 0
for chunk in r.read(1024):
    i += 1
    print i

It fails for me between 10-30 iterations.

@Meano
Copy link
Author

Meano commented Dec 15, 2017

tim 20171215194955

Failed, print error.

@ivankravets
Copy link

Cool! Let's wait when @Tyriar will fix it. I don't know why Python users don't report this issue. Maybe, they don't use built-in terminal :)

@Tyriar
Copy link
Member

Tyriar commented Dec 15, 2017

@rprichard any idea what could be happening here? Interestingly it doesn't seen to happen with @ivankravets's pty.js fork which is still on winpty@0.2 (their Atom extension uses that one).

More info: platformio/platformio-vscode-ide#61

@Tyriar Tyriar added the windows VS Code on Windows issues label Dec 15, 2017
@kzhui125
Copy link

for num in range(0,1000):
    print str(num)

using python 2.7, integrated terminal is unusable now

@rprichard
Copy link

@Tyriar: @segevfiner filed an upstream winpty issue (rprichard/winpty#134). I looked into it, and it looks like a Windows bug, which I filed here: microsoft/terminal#40. I doubt winpty can work around this problem.

FWIW, the legacy console shouldn't be affected by this issue.

It looks like Python 3 is also unaffected. Maybe it uses WriteConsoleW instead of WriteFile.

@khouzam
Copy link

khouzam commented Dec 17, 2017

Thanks, this is indeed a console issue that we've addressed, it's the same issue as #36630.

@Tyriar
Copy link
Member

Tyriar commented Dec 18, 2017

Thanks all! I'll close it out in favor of #36630 then.

@Tyriar Tyriar closed this as completed Dec 18, 2017
@Tyriar Tyriar added the *duplicate Issue identified as a duplicate of another issue(s) label Dec 18, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) terminal Integrated terminal issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests

6 participants