Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lot of tracebacks when interrupting a run with KeyboardInterrupt #2660

Open
Cadair opened this issue Dec 9, 2022 · 2 comments
Open

lot of tracebacks when interrupting a run with KeyboardInterrupt #2660

Cadair opened this issue Dec 9, 2022 · 2 comments
Labels
enhancement help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@Cadair
Copy link

Cadair commented Dec 9, 2022

Issue

I am running a test run and cancelling it often (I am testing migrating to tox 4 and not the package 😀) when I do I get a lot of tracebacks.

Also, if you keyboard interrupt pytest itself then it prints you a test run summary, which isn't printed when interrupting tox

Environment

Provide at least:

  • OS: Linux
  • pip list of the host Python where tox is installed:
Package       Version
------------- -------
cachetools    5.2.0
chardet       5.1.0
colorama      0.4.6
distlib       0.3.6
filelock      3.8.2
packaging     22.0
pip           22.3.1
platformdirs  2.6.0
pluggy        1.0.0
pyproject_api 1.2.1
setuptools    65.6.3
tox           4.0.3
virtualenv    20.17.1
wheel         0.38.4

Output of running tox

Provide the output of tox -rvv:

../../.tox/py310/lib/python3.10/site-packages/sunpy/net/dataretriever/sources/tests/test_lyra_ud.py::test_can_handle_query ^CROOT: [654615] KeyboardInterrupt - teardown started
ROOT: interrupt tox environment: py310
ROOT: requested interrupt of 655013 from 654615, activate in 0.00
ROOT: send signal SIGINT(2) to 655013 from 654615 with timeout 0.30
ROOT: send signal SIGTERM(15) to 655013 from 654615 with timeout 0.20
py310: exit -15 (81.58 seconds) .tmp/py310> pytest --color=yes -vvv -r a --pyargs sunpy --cov-report=xml --cov=sunpy --cov-config=/home/stuart/Git/sunpy/setup.cfg /home/stuart/Git/sunpy/docs pid=655013
.pkg: _exit> python /home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: error while trying to close <_io.BufferedWriter name=6> with BrokenPipeError(32, 'Broken pipe')
ROOT: Internal Error
Traceback (most recent call last):
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/common.py", line 296, in _queue_and_wait
    result = future.result()
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/common.py", line 273, in _run
    return run_one(tox_env, options.parsed.no_test, suspend_display=live is False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/single.py", line 34, in run_one
    skipped, code, outcomes = _evaluate(tox_env, no_test)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/single.py", line 60, in _evaluate
    tox_env.teardown()
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/api.py", line 242, in teardown
    self._teardown()
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/runner.py", line 88, in _teardown
    self._call_pkg_envs("teardown_env", self.conf)
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/runner.py", line 122, in _call_pkg_envs
    getattr(package_env, method_name)(*args)
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/package.py", line 47, in _func
    return meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/package.py", line 103, in teardown_env
    self._teardown()
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/package.py", line 47, in _func
    return meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 164, in _teardown
    self._frontend._send("_exit")  # try first on amicable shutdown
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 333, in _send
    return super()._send(cmd, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/pyproject_api/_frontend.py", line 489, in _send
    with self._send_msg(cmd, result_file, msg) as status:
  File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 352, in _send_msg
    execute_status.write_stdin(f"{msg}{os.linesep}")
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/execute/local_sub_process/__init__.py", line 115, in write_stdin
    stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
Exception in thread tox-interrupt:
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/common.py", line 296, in _queue_and_wait
    result = future.result()
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/common.py", line 273, in _run
    return run_one(tox_env, options.parsed.no_test, suspend_display=live is False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/single.py", line 34, in run_one
    skipped, code, outcomes = _evaluate(tox_env, no_test)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/single.py", line 60, in _evaluate
    tox_env.teardown()
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/api.py", line 242, in teardown
    self._teardown()
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/runner.py", line 88, in _teardown
    self._call_pkg_envs("teardown_env", self.conf)
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/runner.py", line 122, in _call_pkg_envs
    getattr(package_env, method_name)(*args)
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/package.py", line 47, in _func
    return meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/package.py", line 103, in teardown_env
    self._teardown()
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/package.py", line 47, in _func
    return meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 164, in _teardown
    self._frontend._send("_exit")  # try first on amicable shutdown
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 333, in _send
    return super()._send(cmd, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/pyproject_api/_frontend.py", line 489, in _send
    with self._send_msg(cmd, result_file, msg) as status:
  File "/usr/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/tox_env/python/virtual_env/package/pyproject.py", line 352, in _send_msg
    execute_status.write_stdin(f"{msg}{os.linesep}")
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/execute/local_sub_process/__init__.py", line 115, in write_stdin
    stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
ROOT: interrupt finished with success
.pkg: interrupt tox environment: .pkg
Traceback (most recent call last):
  File "/home/stuart/.virtualenvs/sunpy-dev/bin/tox", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/run.py", line 19, in run
    result = main(sys.argv[1:] if args is None else args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/run.py", line 45, in main
    result = handler(state)
             ^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/legacy.py", line 107, in legacy
    return run_sequential(state)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/sequential.py", line 22, in run_sequential
    return execute(state, max_workers=1, has_spinner=False, live=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.11/site-packages/tox/session/cmd/run/common.py", line 226, in execute
    ordered_results.append(name_to_run[env])
                           ~~~~~~~~~~~^^^^^
KeyError: 'py310'

Minimal example

If possible, provide a minimal reproducer for the issue:

tox -e py310
<wait for commands to be run>
Ctrl-C
@geovalexis
Copy link

+1

@gaborbernat
Copy link
Member

+1-s are not useful at all, pull requests are the way to make it happen.

@gaborbernat gaborbernat added help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. enhancement labels Dec 12, 2022
@gaborbernat gaborbernat changed the title Tox 4 prints a lot of tracebacks when interrupting a run with KeyboardInterrupt lot of tracebacks when interrupting a run with KeyboardInterrupt Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

3 participants