Skip to content

Commit

Permalink
Fix locking when saving to cache store
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrob committed Aug 25, 2023
1 parent c9f54ce commit 8f4362c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions emailproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ def write(self, file):
with self.lock:
self.config.write(file)

def items(self):
with self.lock:
return self.config.items() # used in read_dict when saving to cache store


class AppConfig:
"""Helper wrapper around ConfigParser to cache servers/accounts, and avoid writing to the file until necessary"""
Expand Down Expand Up @@ -538,9 +542,8 @@ def save():
if CACHE_STORE != CONFIG_FILE_PATH:
# in `--cache-store` mode we ignore everything except _CACHED_OPTION_KEYS (OAuth 2.0 tokens, etc)
output_config_parser = configparser.ConfigParser()
with AppConfig._PARSER.lock:
output_config_parser.read_dict(AppConfig._PARSER) # a deep copy of the current configuration
config_accounts = AppConfig.accounts()
output_config_parser.read_dict(AppConfig._PARSER) # a deep copy of the current configuration
config_accounts = [s for s in output_config_parser.sections() if '@' in s]

for account in config_accounts:
for option in output_config_parser.options(account):
Expand Down

0 comments on commit 8f4362c

Please sign in to comment.