summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdam Allred <aallred@rsglab.com>2018-10-17 19:47:20 -0400
committerTim Graham <timograham@gmail.com>2018-10-19 20:00:12 -0400
commit4e78e389b16fbceb23d5236ee1650b213e71c968 (patch)
treed367ca9e57e862c92239de4d36ca568ea78b1f13 /django
parenta29fce89845cc9ca2fa96d8880104726b75dfbd6 (diff)
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.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/shell.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
index cff7c73f58..e9d5aa9835 100644
--- a/django/core/management/commands/shell.py
+++ b/django/core/management/commands/shell.py
@@ -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