add warnings about not using async within get_config_lock() get lock contexts

This commit is contained in:
Kyle Altendorf 2022-03-11 21:03:11 -05:00
parent cb7c23d84b
commit 681af3835b
No known key found for this signature in database
GPG Key ID: 5715D880FF005192
3 changed files with 12 additions and 0 deletions

View File

@ -596,6 +596,10 @@ class Farmer:
async def set_payout_instructions(self, launcher_id: bytes32, payout_instructions: str):
for p2_singleton_puzzle_hash, pool_state_dict in self.pool_state.items():
if launcher_id == pool_state_dict["pool_config"].launcher_id:
# WARNING: async activity is not allowed inside get_config_lock()
# TODO: enhance the lock or enforce the restriction
with get_config_lock(self._root_path, "config.yaml"):
config = load_config(self._root_path, "config.yaml", acquire_lock=False)
new_list = []

View File

@ -82,6 +82,10 @@ def add_auth_key(root_path: Path, config_entry: PoolWalletConfig, auth_key: G1El
async def update_pool_config(root_path: Path, pool_config_list: List[PoolWalletConfig]):
# WARNING: async activity is not allowed inside get_config_lock()
# TODO: enhance the lock or enforce the restriction
with get_config_lock(root_path, "config.yaml"):
full_config = load_config(root_path, "config.yaml", acquire_lock=False)
full_config["pool"]["pool_list"] = [c.to_json_dict() for c in pool_config_list]

View File

@ -48,6 +48,10 @@ def config_path_for_filename(root_path: Path, filename: Union[str, Path]) -> Pat
def get_config_lock(root_path: Path, filename: Union[str, Path]) -> BaseFileLock:
# WARNING: async activity is not allowed when inside a get_config_lock() context
# TODO: enhance the lock or enforce the restriction
lock_path: Path = config_path_for_filename(root_path, filename).with_suffix(".lock")
if not lock_path.exists():
lock_path.touch(exist_ok=True)