pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Terminal unresponsive when using ipdb and Django

Open ashchristopher opened this issue 6 years ago • 1 comments

Issue description

When running a Django runserver process, and invoking a import ipdb; ipdb.set_trace(), if you modify a file and the process restarts, your keyboard inputs will not longer be sent through to the new process.

You will be left in a state where your commands will be displayed to the screen however the only course of action will be to kill the process from a different terminal window.

I have tested with pdb and it does not suffer the same behaviour. So very likely limited to ipdb/ipython however given how popular these tools are, and your familiarity with pipenv and it's interaction with other tools in the ecosystem I figure it wouldn't hurt to drop a message here.

Expected result

Keyboard commands would continue to be send to the running process, allowing one to execute normal keyboard functions.

Actual result

ashchristopher@Ashs-Shopify-MacBook-Pro:~/src/github.com/Shopify/django-shopify-app/demo$ pipenv run ./manage.py runserver
Loading .env environment variables…
Performing system checks...

System check identified no issues (0 silenced).
December 24, 2018 - 18:21:53
Django version 2.1.4, using settings 'demo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[24/Dec/2018 18:21:58] "GET /login/ HTTP/1.1" 200 2938
[24/Dec/2018 18:22:00] "POST /login/ HTTP/1.1" 302 0
> /Users/ashchristopher/src/github.com/Shopify/django-shopify-app/shopify_app/views/test.py(32)get()
     31         import ipdb; ipdb.set_trace()
---> 32         # some test code
     33 

ipdb> Error in atexit._run_exitfuncs:                                                                                                                                               
Traceback (most recent call last):
  File "/Users/ashchristopher/.virtualenvs/demo-ZtWU8rHS/lib/python3.7/site-packages/IPython/core/history.py", line 780, in writeout_cache
    self._writeout_input_cache(conn)
  File "/Users/ashchristopher/.virtualenvs/demo-ZtWU8rHS/lib/python3.7/site-packages/IPython/core/history.py", line 764, in _writeout_input_cache
    (self.session_number,)+line)
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 123145547837440 and this is thread id 4613088704.
Performing system checks...

System check identified no issues (0 silenced).
December 24, 2018 - 18:22:07
Django version 2.1.4, using settings 'demo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
^C^C^C^C^Z^Z^Z^Z^C^C^C^C

As you can see, the keyboard commands are sent to the display, but not to the underlying process. This is using a vanilla version of bash.

Steps to replicate

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).

  1. Create a demo Django application, and add a import pdb; pdb.set_trace() in a view.
  2. Run the Django project pipenv run ./manage.py runserver.
  3. Navigate to the associated URL in a browser.
  4. When the program is interrupted, and you are presented with the ipdb console, modify a file and save it.
  5. Try to control-C out of the process.

$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: '/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv'

Python location: '/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/python3.7'

Python installations found:

  • 3.6.5: /Users/ashchristopher/.pyenv/versions/3.6.5/bin/python3
  • 3.6.5: /Users/ashchristopher/.pyenv/versions/3.6.5/bin/python3.6m
  • 2.7.10: /usr/bin/python
  • 2.7.10: /usr/bin/pythonw
  • 2.7.10: /usr/bin/python2.7

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.1',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '18.0.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT '
                     '2018; root:xnu-4903.201.2~1/RELEASE_X86_64',
 'python_full_version': '3.7.1',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • PATH
  • TERM_PROGRAM
  • TERM
  • SHELL
  • CLICOLOR
  • TMPDIR
  • Apple_PubSub_Socket_Render
  • TERM_PROGRAM_VERSION
  • DEV_AUTO_ENV_FEATURES
  • TERM_SESSION_ID
  • LC_ALL
  • USER
  • MACOS_SW_VERSION
  • SSH_AUTH_SOCK
  • USING_DEV
  • WORKON_HOME
  • LSCOLORS
  • VIRTUALENVWRAPPER_PYTHON
  • _
  • PWD
  • LANG
  • CLOUDSDK_PYTHON
  • XPC_FLAGS
  • XPC_SERVICE_NAME
  • SHLVL
  • PYENV_SHELL
  • HOME
  • LANGUAGE
  • LOGNAME
  • SECURITYSESSIONID
  • __CF_USER_TEXT_ENCODING
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/Cellar/pipenv/2018.11.26/libexec/tools:/opt/dev/bin/user:/Users/ashchristopher/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • SHELL: /usr/local/bin/bash
  • LANG: en_CA.UTF-8
  • PWD: /Users/ashchristopher/src/github.com/Shopify/django-shopify-app/demo

Contents of Pipfile ('/Users/ashchristopher/src/github.com/Shopify/django-shopify-app/demo/Pipfile'):

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "3.7"

ashchristopher avatar Dec 24 '18 18:12 ashchristopher

@ashchristopher do you still ask for support with this issue?

matteius avatar Sep 16 '22 04:09 matteius