donkirkby / live-py-plugin

Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser
https://donkirkby.github.io/live-py-plugin
MIT License
291 stars 57 forks source link

RuntimeError: live coding exceeded the 500ms time limit #638

Closed RidaAyed closed 3 months ago

RidaAyed commented 3 months ago

First, let me thank you for that great piece of software. I'm enjoying live-py, but face now problems when using it with unittests. I'm using pytest and a virtual environment (pipenv).

Every keystroke (in buffer test_foo.py) results in RuntimeError: live coding exceeded the 500ms time limit (spacetracer)

Live-py settings

  1. live-py-set-dir: myapp
  2. live-py-set-driver: -m pytest tests/test_foo.py (runs flawlessly from terminal being in myapp$)
  3. live-py-set-version: /home/ra/.local/share/virtualenvs/myapp-Rqr0N7FF/bin/python

Project structure

myapp/ -tests/ --test_foo.py

# In test_foo.py
def test_bla():
    result = 1+1
    assert result == 2

Traceback

Traceback (most recent call last):
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/main.py", line 634, in run_code
    traced_importer.run_main()
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/module_importers.py", line 241, in run_main
    self.run_python_module(self.driver_module)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/module_importers.py", line 276, in run_python_module
    self.run_python_file(pathname, package=packagename)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/module_importers.py", line 322, in run_python_file
    exec(code, main_mod.__dict__)
  File "/home/ra/.local/share/virtualenvs/myapp-Rqr0N7FF/lib/python3.8/site-packages/pytest/__main__.py", line 7, in <module>
    raise SystemExit(pytest.console_main())
SystemExit: ExitCode.TESTS_FAILED

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/main.py", line 463, in trace_command
    self.run_code(args.bad_driver, traced_importer)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/main.py", line 646, in run_code
    traced_importer.report_driver_result([message])
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/module_importers.py", line 375, in report_driver_result
    self.report_builder.start_block(1, block_size)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/report_builder.py", line 91, in start_block
    self.check_time_limit()
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/report_builder.py", line 102, in check_time_limit
    raise RuntimeError('live coding exceeded the {} time limit'.format(
RuntimeError: live coding exceeded the 500ms time limit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ra/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/ra/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/__main__.py", line 6, in <module>
    main()
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/main.py", line 187, in main
    code_report = tracer.trace_command()
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/main.py", line 507, in trace_command
    traced_importer.report_driver_result(messages)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/module_importers.py", line 375, in report_driver_result
    self.report_builder.start_block(1, block_size)
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/report_builder.py", line 91, in start_block
    self.check_time_limit()
  File "/home/ra/.emacs.default/elpa/29.3/develop/live-py-mode-20240602.513/space_tracer/report_builder.py", line 102, in check_time_limit
    raise RuntimeError('live coding exceeded the {} time limit'.format(
RuntimeError: live coding exceeded the 500ms time limit

System Info :computer:

```elisp ((spacemacs-layouts :variables spacemacs-layouts-restrict-spc-tab t) systemd graphviz (spell-checking :variables spell-checking-enable-by-default nil spell-checking-enable-auto-dictionary t enable-flyspell-auto-completion t) yaml (json :variables json-fmt-tool 'web-beautify) latex pass csv prodigy (treemacs :variables treemacs-use-all-the-icons-theme t) search-engine (auto-completion :variables auto-completion-enable-snippets-in-popup t auto-completion-enable-help-tooltip t auto-completion-return-key-behavior 'complete auto-completion-tab-key-behavior 'cycle auto-completion-enable-sort-by-usage t auto-completion-idle-delay 0.2 auto-completion-minimum-prefix-length 2) exwm emacs-lisp git helm finance (org :variables org-enable-hugo-support t org-enable-github-support t) (shell :variables shell-default-shell 'ansi-term shell-default-height 30 shell-default-position 'right spacemacs-vterm-history-file-location "~/.bashhistory") (version-control :packages (not git-gutter)) mu4e pdf (python :variables python-backend 'lsp python-lsp-server 'pyright python-test-runner 'pytest)) ```

donkirkby commented 3 months ago

I've bumped the timeout to 10s, to match what I use on other platforms. It still seems odd that a trivial Pytest call would take more than half a second. Have you got other Pytest plugins installed?