Skip to content

Commit 7ab4f80

Browse files
committed
trying to fix the windows error
1 parent cc052ff commit 7ab4f80

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
import sys
23
from typing import Iterable, overload, Any
34

45
import nicegui.context
@@ -7,6 +8,24 @@
78
from nicegui.testing import UserInteraction
89
from nicegui.testing.user import User
910

11+
if sys.platform == "win32":
12+
# Python 3.14 on Windows: nicegui's storage teardown races with subprocess shutdown,
13+
# leaving storage-general.json locked (WinError 32). Patch only FilePersistentDict.clear
14+
# so the retry sleep never runs inside the async event loop.
15+
import time
16+
from nicegui.persistence import file_persistent_dict as _fpd
17+
18+
_orig_clear = _fpd.FilePersistentDict.clear
19+
20+
def _safe_clear(self: _fpd.FilePersistentDict) -> None:
21+
try:
22+
_orig_clear(self)
23+
except PermissionError:
24+
time.sleep(0.5)
25+
_orig_clear(self)
26+
27+
_fpd.FilePersistentDict.clear = _safe_clear # type: ignore[method-assign]
28+
1029

1130
@pytest.fixture(autouse=True)
1231
def reset_nicegooey_main():

0 commit comments

Comments
 (0)