Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Live update config file without restarting (RFC) #535

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix pyright errors
  • Loading branch information
Alex O committed Feb 6, 2024
commit 5024cf83444ad6d68a979c0ec13fb045888cab12
2 changes: 1 addition & 1 deletion flathunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def launch_flat_hunt(config, heartbeat: Heartbeat):
if config_handle is not None:
new_config = Config(filename=config_handle.name, silent=True)

if None in (config.last_modified_time, new_config.last_modified_time):
if config.last_modified_time is None or new_config.last_modified_time is None:
logger.warning("Could not compare last modification time of config file."
"Keeping the old configuration")
elif config.last_modified_time < new_config.last_modified_time:
Expand Down
7 changes: 6 additions & 1 deletion flathunter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ def __init__(self, config=None):
self.config = config
self.__searchers__ = []
self.check_deprecated()
self.last_modified_time: Optional[float] = self.get_last_modified_time(self.config.get("filename"))
if filename := self.config.get("filename"):
self.last_modified_time: Optional[float] = self.get_last_modified_time(filename)
else:
self.last_modified_time: Optional[float] = None



def __iter__(self):
"""Emulate dictionary"""
Expand Down