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

Fix stack overflow triggered by casefolding script #405

Merged
merged 10 commits into from
Sep 28, 2021
1 change: 1 addition & 0 deletions changelog.d/405.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix stack overflow caused by settign up logging multiple times in casefolding script.
Azrenbeth marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion scripts/casefold_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def update_global_associations(
sys.exit(1)

sydent_config = SydentConfig()
sydent_config.parse_config_file(args.config_path)
sydent_config.parse_config_file(args.config_path, skip_logging_setup=True)

reactor = ResolvingMemoryReactorClock()
sydent = Sydent(sydent_config, reactor, False)
Expand Down
7 changes: 5 additions & 2 deletions sydent/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ def parse_from_config_parser(self, cfg: ConfigParser) -> bool:
"""
return self._parse_config(cfg)

def parse_config_file(self, config_file: str) -> None:
def parse_config_file(
self, config_file: str, skip_logging_setup: bool = False
) -> None:
"""
Parse the given config from a filepath, populating missing items and
sections. NOTE: this method also sets up logging.
Azrenbeth marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -238,7 +240,8 @@ def parse_config_file(self, config_file: str) -> None:

# Logging is configured in cfg, but these options must be parsed first
# so that we can log while parsing the rest
setup_logging(cfg)
if not skip_logging_setup:
setup_logging(cfg)

# TODO: Don't alter config file when starting Sydent so that
# it can be set to read-only
Expand Down
2 changes: 1 addition & 1 deletion sydent/sydent.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def run_gc():

if __name__ == "__main__":
sydent_config = SydentConfig()
sydent_config.parse_config_file(get_config_file_path())
sydent_config.parse_config_file(get_config_file_path(), skip_logging_setup=False)

syd = Sydent(sydent_config)
syd.run()