diff --git a/moto/iam/models.py b/moto/iam/models.py index 6ca24dda0..3177c4780 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -69,7 +69,8 @@ SERVICE_NAME_CONVERSION = { def get_account_id_from(access_key: str) -> str: - for account_id, account in iam_backends.items(): + # wrapped in a list() to avoid thread pooling problems (issue #5881) + for account_id, account in list(iam_backends.items()): if access_key in account["global"].access_keys: return account_id return DEFAULT_ACCOUNT_ID