Skip to content

Commit

Permalink
WIP: fix open files issue with whoosh-reloaded and test_index_update
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichB22 committed Apr 9, 2024
1 parent 41267f8 commit 71b027b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies = [
"markupsafe <= 2.2.0", # safe html and xml
"pygments >= 1.4", # src code / text file highlighting
"Werkzeug >= 3.0.0", # WSGI toolkit
"whoosh >= 2.7.0", # needed for indexed search
"whoosh-reloaded >= 2.7.5", # needed for indexed search
"pdfminer.six", # pdf -> text/plain conversion
"passlib >= 1.6.0", # strong password hashing (1.6 needed for consteq)
"sqlalchemy < 2.0", # used by sqla store
Expand Down
10 changes: 6 additions & 4 deletions src/moin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright: 2007 MoinMoin:AlexanderSchremmer
# Copyright: 2008,2011 MoinMoin:ThomasWaldmann
# Copyright: 2023 MoinMoin project
# Copyright: 2024 MoinMoin:UlrichB
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand All @@ -16,6 +17,7 @@
use a Config class to define the required configuration within the test class.
"""

import gc
import pytest
import py

Expand Down Expand Up @@ -64,11 +66,11 @@ def app_ctx(cfg):
teardown_wiki("")
ctx.pop()
try:
# simulate ERROR PermissionError:
# [WinError 32] The process cannot access the file because it is being used by another process
assert [] == get_open_wiki_files()
finally:
destroy_app(app)
except PermissionError: # [WinError 32] ... the file is being used by another process
gc.collect() # triggers close of index files
destroy_app(app)
assert len(get_open_wiki_files()) < 1


@pytest.fixture(autouse=True)
Expand Down
3 changes: 1 addition & 2 deletions src/moin/storage/middleware/indexing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright: 2011 MoinMoin:RonnyPfannschmidt
# Copyright: 2011 MoinMoin:ThomasWaldmann
# Copyright: 2011 MoinMoin:MichaelMayorov
# Copyright: 2024 MoinMoin:UlrichB
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -48,7 +49,6 @@
usually it is even just the small and thus quick latest-revs index.
"""

import gc
import os
import sys
import shutil
Expand Down Expand Up @@ -1287,7 +1287,6 @@ def store_revision(
backend_name, revid = backend.store(meta, data)
meta[REVID] = revid
self.indexer.index_revision(meta, content, backend_name, force_latest=not overwrite)
gc.collect() # triggers close of index files from is_latest search
if not overwrite:
self._current = get_indexer(self.indexer._document, revid=revid)
if return_rev:
Expand Down

0 comments on commit 71b027b

Please sign in to comment.