Skip to content

Commit

Permalink
fix: Correct the type of shelf files
Browse files Browse the repository at this point in the history
in internal_server and address_space.
Path.is_file does not consume strings,
as shelf.open does only consume string and not pathlib.Path.
  • Loading branch information
AiyionPrime authored and oroulet committed Feb 16, 2024
1 parent cf2bd66 commit 26bf738
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion asyncua/server/address_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def make_aspace_shelf(self, path: Path):
Note: Intended for slow devices, such as Raspberry Pi, to greatly improve start up time
"""
with shelve.open(path, 'n', protocol=pickle.HIGHEST_PROTOCOL) as s:
with shelve.open(str(path), 'n', protocol=pickle.HIGHEST_PROTOCOL) as s:
for nodeid, ndata in self._nodes.items():
s[nodeid.to_string()] = ndata

Expand Down
2 changes: 1 addition & 1 deletion asyncua/server/internal_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def load_standard_address_space(self, shelf_file: Optional[Path] = None):
if shelf_file:
is_file = await asyncio.get_running_loop().run_in_executor(
None, Path.is_file, shelf_file
) or await asyncio.get_running_loop().run_in_executor(None, Path.is_file, f'{shelf_file}.db')
) or await asyncio.get_running_loop().run_in_executor(None, Path.is_file, shelf_file / '.db')
if is_file:
# import address space from shelf
await asyncio.get_running_loop().run_in_executor(None, self.aspace.load_aspace_shelf, shelf_file)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ def test_sync_server_get_node(server, idx):
assert vars[0].read_value() == 6.7


@pytest.mark.xfail(
raises=AttributeError, reason="asyncua introduced a regression, likely when we switched to pathlib", strict=True
)
async def test_sync_server_creating_shelf_files_works(tloop: ThreadLoop, tmp_path: Path) -> None:
shelf_file_path: Path = tmp_path / "shelf_file"

Expand Down

0 comments on commit 26bf738

Please sign in to comment.