Skip to content
New issue

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

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

Already on GitHub? # to your account

ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7f124b715b70> #1357

Closed
mwouts opened this issue Mar 10, 2025 · 1 comment · Fixed by #1359
Closed

ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7f124b715b70> #1357

mwouts opened this issue Mar 10, 2025 · 1 comment · Fixed by #1359

Comments

@mwouts
Copy link
Owner

mwouts commented Mar 10, 2025

That is another intermittent error on the CI, seen for instance at https://github.com/mwouts/jupytext/actions/runs/13753847186/job/38459674477?pr=1315

__________________________ test_format_prefix_suffix ___________________________
[gw2] linux -- Python 3.13.2 /opt/hostedtoolcache/Python/3.13.2/x64/bin/python

cls = <class '_pytest.runner.CallInfo'>
func = <function call_and_report.<locals>.<lambda> at 0x7f123fcf0c20>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: Callable[[], TResult],
        when: Literal["collect", "setup", "call", "teardown"],
        reraise: type[BaseException] | tuple[type[BaseException], ...] | None = None,
    ) -> CallInfo[TResult]:
        """Call func, wrapping the result in a CallInfo.
    
        :param func:
            The function to call. Called without arguments.
        :type func: Callable[[], _pytest.runner.TResult]
        :param when:
            The phase in which the function is called.
        :param reraise:
            Exception or exceptions that shall propagate if raised by the
            function, instead of being wrapped in the CallInfo.
        """
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: TResult | None = func()

/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/_pytest/runner.py:341: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/_pytest/runner.py:242: in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/pluggy/_hooks.py:513: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/pluggy/_manager.py:120: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/_pytest/threadexception.py:92: in pytest_runtest_call
    yield from thread_exception_runtest_hook()
/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/_pytest/threadexception.py:68: in thread_exception_runtest_hook
    yield
/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/_pytest/unraisableexception.py:95: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def unraisable_exception_runtest_hook() -> Generator[None]:
        with catch_unraisable_exception() as cm:
            try:
                yield
            finally:
                if cm.unraisable:
                    if cm.unraisable.err_msg is not None:
                        err_msg = cm.unraisable.err_msg
                    else:
                        err_msg = "Exception ignored in"
                    msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                    msg += "".join(
                        traceback.format_exception(
                            cm.unraisable.exc_type,
                            cm.unraisable.exc_value,
                            cm.unraisable.exc_traceback,
                        )
                    )
>                   warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E                   pytest.PytestUnraisableExceptionWarning: Exception ignored in: <sqlite3.Connection object at 0x7f124b715b70>
E                   
E                   Traceback (most recent call last):
E                     File "<frozen os>", line 793, in encode
E                   ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7f124b715b70>

/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/_pytest/unraisableexception.py:85: PytestUnraisableExceptionWarning
----------------------------- Captured stdout call -----------------------------
[jupytext] Reading notebooks/notebook_name.ipynb in format ipynb
[jupytext] Writing scripts/notebook_name.py
[jupytext] Reading notebooks/notebook_name.ipynb in format notebooks//ipynb
[jupytext] Writing scripts/notebook_name.py
[jupytext] Reading notebooks/nb_prefix_notebook_name.ipynb in format notebooks/nb_prefix_/ipynb
[jupytext] Writing scripts/script_prefix_notebook_name.py
[jupytext] Reading notebooks/nb_prefix_notebook_name_nb_suffix.ipynb in format notebooks/nb_prefix_/_nb_suffix.ipynb
[jupytext] Writing scripts/script_prefix_notebook_name_script_suffix.py
------------------------------ Captured log call -------------------------------
WARNING  root:jupytext.py:594 [jupytext] creating missing directory scripts/
=============================== warnings summary ===============================
tests/external/jupyter_fs/test_jupyter_fs.py::test_jupytext_jupyter_fs_metamanager[async]
  /opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/traitlets/traitlets.py:3615: DeprecationWarning: metadata {'per_key_traits': <traitlets.traitlets.Dict object at 0x7f03e99bc7e0>} was set from the constructor. With traitlets 4.1, metadata should be set using the .tag() method, e.g., Int().tag(key1='value1', key2='value2')
    super().__init__(trait=trait, default_value=default_value, **kwargs)

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

---------- coverage: platform linux, python 3.13.2-final-0 -----------
Coverage XML written to file coverage.xml

=========================== short test summary info ============================
FAILED tests/functional/cli/test_cli.py::test_format_prefix_suffix - pytest.PytestUnraisableExceptionWarning: Exception ignored in: <sqlite3.Connection object at 0x7f124b715b70>

Traceback (most recent call last):
  File "<frozen os>", line 793, in encode
ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7f124b715b70>
====== 1 failed, 3722 passed, 257 skipped, 1 warning in 152.99s (0:02:32) ======
@mwouts
Copy link
Owner Author

mwouts commented Mar 11, 2025

Another occurrence here, I will try adding an ignore to filterwarnings in [tool.pytest.ini_options]

mwouts added a commit that referenced this issue Mar 11, 2025
mwouts added a commit that referenced this issue Mar 11, 2025
mwouts added a commit that referenced this issue Mar 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant