﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29774	`django-admin shell` hangs if the user starts typing before shell is ready	Craig de Stigter	nobody	"We have a large project with a fairly slow startup time:

{{{
$ time bash -c ""echo 'pass' | django-admin shell""

real	0m5.596s
user	0m1.080s
sys	0m1.548s
}}}

As a habit, I tend to run `django-admin shell`, and while it's loading, begin to type my first command.

Since upgrading from django 1.8 to 1.11, this causes the whole process to hang with no output. After about 30s I notice and ctrl+C, but it's incredibly frustrating:

{{{
$ django-admin shell
typing while i wait...
^CTraceback (most recent call last):
  File ""/kx/dandelion/venv/bin/django-admin"", line 11, in <module>
    sys.exit(execute_from_command_line())
  File ""/kx/dandelion/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 364, in execute_from_command_line
    utility.execute()
  File ""/kx/dandelion/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/kx/dandelion/venv/local/lib/python2.7/site-packages/django/core/management/base.py"", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/kx/dandelion/venv/local/lib/python2.7/site-packages/django/core/management/base.py"", line 330, in execute
    output = self.handle(*args, **options)
  File ""/kx/dandelion/venv/local/lib/python2.7/site-packages/django/core/management/commands/shell.py"", line 101, in handle
    exec(sys.stdin.read())
KeyboardInterrupt
}}}


Multiple people on our team have experienced this.

It seems to happen if I manage to type at least one line before it loads. If I just type a few characters not including a newline, the hang doesn't occur.

I traced the issue to [https://github.com/django/django/commit/bf6392bb7565c21f01ed6f682b8558dcf1cc8070#diff-e38db80a1fef4134e3850b467d8d2344R127 this addition] in the django 1.11 release. It is still present in master.
"	Bug	new	Core (Management commands)	dev	Normal		hang, shell		Unreviewed	0	0	0	0	0	0
