Skip to content

Commit 0ab24df

Browse files
committed
Fix Python 3.9 module import race condition in contract tests
Add eager import of utils.retries module to prevent KeyError in module lock when templates.py triggers lazy import via __getattr__. This is a known Python 3.9 issue with nested imports that was fixed in 3.10+. The urllib3 upgrade changed import timing enough to expose this latent bug in the lazy loading mechanism.
1 parent c6e9e11 commit 0ab24df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

_test_contract/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
from unstructured_client import UnstructuredClient, utils
99

10+
# Python 3.9 workaround: eagerly import retries to avoid lazy import race condition
11+
# This prevents a KeyError in module lock when templates.py triggers lazy import of utils.retries
12+
from unstructured_client.utils import retries # noqa: F401
13+
1014
FAKE_API_KEY = "91pmLBeETAbXCpNylRsLq11FdiZPTk"
1115

1216

0 commit comments

Comments
 (0)