Repository navigation
Closed
Description
I just created a simple tasks file on Windows:
from invoke import task, run
@task
def foo():
print("Hello, world!")
run("echo Hi")
When I try to run it (invoke 0.12.0, Python 3.5.0 64-bit) on Windows 7, I get the following error:
>inv foo
Hello, world!
Hi
Traceback (most recent call last):
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\UK03306\AppData\Local\Programs\Python\Python35\Scripts\inv.exe\__main__.py", line 9, in <module>
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\program.py", line 270, in run
self.execute()
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\program.py", line 379, in execute
executor.execute(*self.tasks)
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\executor.py", line 114, in execute
result = call.task(*args, **call.kwargs)
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\tasks.py", line 113, in __call__
result = self.body(*args, **kwargs)
File "C:\Work\Scratch\tasks.py", line 5, in foo
run("echo Hi")
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\__init__.py", line 27, in run
return Context().run(command, **kwargs)
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\context.py", line 53, in run
return runner_class(context=self).run(command, **kwargs)
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\runners.py", line 232, in run
raise ThreadException(exceptions)
invoke.exceptions.ThreadException:
Saw 1 exceptions within threads (OSError):
Thread args: {'kwargs': {'input_': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='cp437'>},
'target': <bound method Runner.handle_stdin of <invoke.runners.Local object at 0x0000000002FDA780>>}
Traceback (most recent call last):
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\runners.py", line 804, in run
super(_IOThread, self).run()
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\threading.py", line 871, in run
self._target(*self._args, **self._kwargs)
File "c:\users\uk03306\appdata\local\programs\python\python35\lib\site-packages\invoke\runners.py", line 411, in handle_stdin
reads, _, _ = select.select([input_], [], [], 0.0)
OSError: [WinError 10093] Either the application has not called WSAStartup, or WSAStartup failed
Note that the task output appears fine, so it's not clear what's going on here. Is it possible that invoke is trying to use select.select on sys.stdin? That's not allowed on Windows, you can only use select on sockets...
Activity
pfmoore commentedon Jan 13, 2016
Yes, confirmed.
Runner.handle_stdinsetsuse_selectwhenisatty(input_)is true. That's what triggers trying to useselecton a non-socket stream. But simply usingFalseforuse_selectbreaks, as the program hangs waiting for input, and then fails inwrite_stdin.[-]select/threading error on Windows[/-][+]Stdin handling for terminals is broken on Windows[/+]pfmoore commentedon Jan 14, 2016
PR #304 seems to fix this (based on a relatively straightforward test). At least for simple cases,
run()is no longer totally broken on Windows.Note that I'd view this as a critical fix - with this bug, invoke 0.12.0 is essentially unusable on Windows.
presidento commentedon Jan 14, 2016
👍
bitprophet commentedon Jan 29, 2016
Should be fixed as per discussions in #289 and #304.