1
0
mirror of https://github.com/django/django.git synced 2024-12-22 09:05:43 +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:
Adam Allred 2018-10-17 19:47:20 -04:00 committed by Tim Graham
parent a29fce8984
commit 4e78e389b1
3 changed files with 5 additions and 1 deletions

View File

@ -11,6 +11,7 @@ answer newbie questions, and generally made Django that much better:
Abeer Upadhyay <ab.esquarer@gmail.com> Abeer Upadhyay <ab.esquarer@gmail.com>
Abhinav Patil <https://github.com/ubadub/> Abhinav Patil <https://github.com/ubadub/>
Abhishek Gautam <abhishekg1128@yahoo.com> Abhishek Gautam <abhishekg1128@yahoo.com>
Adam Allred <adam.w.allred@gmail.com>
Adam Bogdał <adam@bogdal.pl> Adam Bogdał <adam@bogdal.pl>
Adam Donaghy Adam Donaghy
Adam Johnson <https://github.com/adamchainz> Adam Johnson <https://github.com/adamchainz>

View File

@ -88,7 +88,7 @@ class Command(BaseCommand):
# Execute stdin if it has anything to read and exit. # Execute stdin if it has anything to read and exit.
# Not supported on Windows due to select.select() limitations. # 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()) exec(sys.stdin.read())
return return

View File

@ -11,3 +11,6 @@ Bugfixes
* Fixed a regression in Django 2.0 where combining ``Q`` objects with ``__in`` * Fixed a regression in Django 2.0 where combining ``Q`` objects with ``__in``
lookups and lists crashed (:ticket:`29838`). lookups and lists crashed (:ticket:`29838`).
* Fixed a regression in Django 1.11 where ``django-admin shell`` may hang
on startup (:ticket:`29774`).