Minimum working example:
test.bat:
@echo off
if 0==0 (
timeout 3
python test.py
)
test.py:
input('press ENTER to exit')
In cmd.exe:
call test.bat
> Waiting for 0 seconds, press a key to continue ...
> press ENTER to exit_
Then it's stuck at the input statement. If I keep pressing enter, it will eventually raise an exception:
Traceback (most recent call last):
File "test.py", line 1, in <module>
input('press ENTER to exit')
OSError: [WinError 8] Not enough storage is available to process this command
I'm on Windows 7 SP1, tried it with
Can anyone reproduce this and/or have any idea where it went wrong?
I can reproduce the issue on Windows 7 with Python 3.6.5 64 bit.
A couple of alternatives to avoid the issue with timeout:
@echo off
if 0==0 (
echo Pause for 3 seconds
ping -n 3 localhost >nul
python test.py
)
exit /b
This uses ping which causes no issue.
@echo off
if 0==0 (
timeout 3
call :run_python test.py
)
exit /b
:run_python
python %*
exit /b
This uses a label named :run_python which allows the interpreter to run Python outside the context of the parentheses. Any arguments passed following the called label will be passed to python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With