Skip to content

Thread unsafety with 3.13t: "ValueError: tool 1 is not in use" #1970

@nedbat

Description

@nedbat

This happens occasionally when running the full test suite on my Mac:

tests/test_concurrency.py::test_thread_safe_save_data
  /Users/ned/coverage/trunk/.tox/py313t/lib/python3.13t/site-packages/_pytest/threadexception.py:82: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-10 (random_load)

  Traceback (most recent call last):
    File "/usr/local/pyenv/pyenv/versions/3.13.3t/lib/python3.13t/threading.py", line 1041, in _bootstrap_inner
      self.run()
      ~~~~~~~~^^
    File "/usr/local/pyenv/pyenv/versions/3.13.3t/lib/python3.13t/threading.py", line 992, in run
      self._target(*self._args, **self._kwargs)
      ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/ned/coverage/trunk/tests/test_concurrency.py", line 673, in random_load
      mod = import_local_file(module_name)
    File "/Users/ned/coverage/trunk/coverage/misc.py", line 300, in import_local_file
      spec.loader.exec_module(mod)
      ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
    File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
    File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
    File "/private/var/folders/6j/khn0mcrj35d1k3yylpl8zl080000gn/T/pytest-of-ned/pytest-14/popen-gw1/test_thread_safe_save_data0/test_modules/m192.py", line 0, in <module>


      def f(): pass

    File "/Users/ned/coverage/trunk/coverage/sysmon.py", line 369, in sysmon_py_start
      sys_monitoring.set_local_events(self.myid, code, local_events)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ValueError: tool 1 is not in use

    warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions