Commit cf2bd668 authored by Jan-Niklas Burfeind's avatar Jan-Niklas Burfeind Committed by oroulet

chore: Add typehints for the optional shelf file

to clarify its intended usage.
parent f41b67e1
...@@ -9,6 +9,7 @@ import shelve ...@@ -9,6 +9,7 @@ import shelve
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from datetime import datetime from datetime import datetime
from functools import partial from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING, Optional from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING: if TYPE_CHECKING:
...@@ -697,7 +698,7 @@ class AddressSpace: ...@@ -697,7 +698,7 @@ class AddressSpace:
with open(path, 'rb') as f: with open(path, 'rb') as f:
self._nodes = pickle.load(f) self._nodes = pickle.load(f)
def make_aspace_shelf(self, path): def make_aspace_shelf(self, path: Path):
""" """
Make a shelf for containing the nodes from the standard address space; this is typically only done on first Make a shelf for containing the nodes from the standard address space; this is typically only done on first
start of the server. Subsequent server starts will load the shelf, nodes are then moved to a cache start of the server. Subsequent server starts will load the shelf, nodes are then moved to a cache
......
...@@ -80,7 +80,7 @@ class InternalServer: ...@@ -80,7 +80,7 @@ class InternalServer:
self.match_discovery_source_ip: bool = True self.match_discovery_source_ip: bool = True
self.supported_tokens = [] self.supported_tokens = []
async def init(self, shelffile=None): async def init(self, shelffile: Optional[Path] = None):
await self.load_standard_address_space(shelffile) await self.load_standard_address_space(shelffile)
await self._address_space_fixes() await self._address_space_fixes()
await self.setup_nodes() await self.setup_nodes()
...@@ -135,7 +135,7 @@ class InternalServer: ...@@ -135,7 +135,7 @@ class InternalServer:
result = await self.isession.write(params) result = await self.isession.write(params)
result[0].check() result[0].check()
async def load_standard_address_space(self, shelf_file=None): async def load_standard_address_space(self, shelf_file: Optional[Path] = None):
if shelf_file: if shelf_file:
is_file = await asyncio.get_running_loop().run_in_executor( is_file = await asyncio.get_running_loop().run_in_executor(
None, Path.is_file, shelf_file None, Path.is_file, shelf_file
......
...@@ -121,7 +121,7 @@ class Server: ...@@ -121,7 +121,7 @@ class Server:
max_message_size=max_msg_sz max_message_size=max_msg_sz
) )
async def init(self, shelf_file=None): async def init(self, shelf_file: Optional[Path] = None):
await self.iserver.init(shelf_file) await self.iserver.init(shelf_file)
# setup some expected values # setup some expected values
await self.set_application_uri(self._application_uri) await self.set_application_uri(self._application_uri)
......
...@@ -537,7 +537,7 @@ class Server: ...@@ -537,7 +537,7 @@ class Server:
waits for an async call to return. defualt is 120s and hopefully should fit most applications waits for an async call to return. defualt is 120s and hopefully should fit most applications
""" """
def __init__(self, shelf_file=None, tloop=None, sync_wrapper_timeout: Optional[float] = 120,): def __init__(self, shelf_file: Optional[Path] = None, tloop=None, sync_wrapper_timeout: Optional[float] = 120,):
self.tloop = tloop self.tloop = tloop
self.close_tloop = False self.close_tloop = False
if not self.tloop: if not self.tloop:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment