mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #29774 -- Fixed django-admin shell hang on startup.
sys.stdin.read() blocks waiting for EOF in shell.py which will likely never come if the user provides input on stdin via the keyboard before the shell starts. Added check for a tty to skip reading stdin if it's not present. This still allows piping of code into the shell (which should have no TTY and should have an EOF) but also doesn't cause it to hang if multi-line input is provided.
This commit is contained in:
@@ -88,7 +88,7 @@ class Command(BaseCommand):
|
||||
|
||||
# Execute stdin if it has anything to read and exit.
|
||||
# Not supported on Windows due to select.select() limitations.
|
||||
if sys.platform != 'win32' and select.select([sys.stdin], [], [], 0)[0]:
|
||||
if sys.platform != 'win32' and not sys.stdin.isatty() and select.select([sys.stdin], [], [], 0)[0]:
|
||||
exec(sys.stdin.read())
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user