Skip to content

Commit f393998

Browse files
committed
bugfix: threading id means nothing for async, use loop id
- Asynchronous code making use of a threading ``id`` for the cache key doesn't make as much sense as using a loop ``id``. Running the core tests with ``pytest-xdist`` runners actually seems to have identified a bug in this code that was previously well hidden. Replace the threading id with loop id when generating unique cache keys in the http session manager.
1 parent 8d52711 commit f393998

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

web3/_utils/http_session_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ async def async_cache_and_return_session(
178178
request_timeout: Optional[ClientTimeout] = None,
179179
) -> ClientSession:
180180
# cache key should have a unique thread identifier
181-
cache_key = generate_cache_key(f"{threading.get_ident()}:{endpoint_uri}")
181+
cache_key = generate_cache_key(f"{id(asyncio.get_event_loop())}:{endpoint_uri}")
182182

183183
evicted_items = None
184184
async with async_lock(self.session_pool, self._lock):

0 commit comments

Comments
 (0)