|
1 | 1 | import asyncio |
2 | | -import gc |
3 | 2 | import json |
4 | 3 | import threading |
5 | 4 | from concurrent.futures import ThreadPoolExecutor |
@@ -214,25 +213,6 @@ def test_sync_envd_transport_uses_separate_stack(test_api_key): |
214 | 213 | reset_sync_envd_transports() |
215 | 214 |
|
216 | 215 |
|
217 | | -def test_sync_api_transport_cache_is_shared_across_threads(test_api_key): |
218 | | - # pyqwest transports are thread-safe, so all threads share one connection |
219 | | - # pool per proxy (the httpx transports this replaced were per-thread). |
220 | | - reset_sync_api_transports() |
221 | | - config = ConnectionConfig(api_key=test_api_key) |
222 | | - |
223 | | - try: |
224 | | - main_transport = get_sync_transport(config) |
225 | | - same_thread_transport = get_sync_transport(config) |
226 | | - worker_thread_transport = run_in_worker_thread( |
227 | | - lambda: get_sync_transport(config) |
228 | | - ) |
229 | | - |
230 | | - assert same_thread_transport is main_transport |
231 | | - assert worker_thread_transport is main_transport |
232 | | - finally: |
233 | | - reset_sync_api_transports() |
234 | | - |
235 | | - |
236 | 216 | def test_sync_api_client_is_shared_across_threads(test_api_key): |
237 | 217 | # httpx.Client is thread-safe and the pyqwest transport underneath is |
238 | 218 | # too, so a single client (and its pool) serves all threads — the |
@@ -311,21 +291,6 @@ async def test_async_get_transport_keyed_by_proxy(test_api_key): |
311 | 291 | reset_async_api_transports() |
312 | 292 |
|
313 | 293 |
|
314 | | -@pytest.mark.asyncio |
315 | | -async def test_async_api_client_applies_request_timeout(test_api_key): |
316 | | - reset_async_api_transports() |
317 | | - config = ConnectionConfig(api_key=test_api_key, request_timeout=1.5) |
318 | | - |
319 | | - api_client = get_async_api_client(config) |
320 | | - httpx_client = api_client.get_async_httpx_client() |
321 | | - |
322 | | - try: |
323 | | - assert httpx_client.timeout == httpx.Timeout(1.5) |
324 | | - finally: |
325 | | - await httpx_client.aclose() |
326 | | - reset_async_api_transports() |
327 | | - |
328 | | - |
329 | 294 | @pytest.mark.asyncio |
330 | 295 | async def test_async_api_client_is_shared_across_loops(test_api_key): |
331 | 296 | # pyqwest's I/O runs on its own Rust runtime, so neither the transport |
@@ -353,67 +318,6 @@ async def get_client(): |
353 | 318 | reset_async_api_transports() |
354 | 319 |
|
355 | 320 |
|
356 | | -def test_async_transport_reused_across_sequential_loops(test_api_key): |
357 | | - reset_async_api_transports() |
358 | | - config = ConnectionConfig(api_key=test_api_key) |
359 | | - |
360 | | - async def get_transport(): |
361 | | - return get_async_transport(config) |
362 | | - |
363 | | - try: |
364 | | - loop_a = asyncio.new_event_loop() |
365 | | - try: |
366 | | - transport_a = loop_a.run_until_complete(get_transport()) |
367 | | - finally: |
368 | | - loop_a.close() |
369 | | - del loop_a |
370 | | - gc.collect() |
371 | | - |
372 | | - # The transport is not bound to an event loop, so it survives the |
373 | | - # loop it was first created on. |
374 | | - loop_b = asyncio.new_event_loop() |
375 | | - try: |
376 | | - transport_b = loop_b.run_until_complete(get_transport()) |
377 | | - finally: |
378 | | - loop_b.close() |
379 | | - |
380 | | - assert transport_b is transport_a |
381 | | - finally: |
382 | | - reset_async_api_transports() |
383 | | - |
384 | | - |
385 | | -def test_async_api_client_reused_across_sequential_loops(test_api_key): |
386 | | - # A closed loop doesn't strand the client: nothing in it is loop-bound, |
387 | | - # so a later loop reuses the same client and shared transport. |
388 | | - reset_async_api_transports() |
389 | | - config = ConnectionConfig(api_key=test_api_key) |
390 | | - api_client = get_async_api_client(config) |
391 | | - |
392 | | - async def get_client(): |
393 | | - client = api_client.get_async_httpx_client() |
394 | | - assert api_client.get_async_httpx_client() is client |
395 | | - return client |
396 | | - |
397 | | - try: |
398 | | - loop_a = asyncio.new_event_loop() |
399 | | - try: |
400 | | - client_a = loop_a.run_until_complete(get_client()) |
401 | | - finally: |
402 | | - loop_a.close() |
403 | | - del loop_a |
404 | | - gc.collect() |
405 | | - |
406 | | - loop_b = asyncio.new_event_loop() |
407 | | - try: |
408 | | - client_b = loop_b.run_until_complete(get_client()) |
409 | | - finally: |
410 | | - loop_b.close() |
411 | | - |
412 | | - assert client_b is client_a |
413 | | - finally: |
414 | | - reset_async_api_transports() |
415 | | - |
416 | | - |
417 | 321 | @pytest.mark.asyncio |
418 | 322 | async def test_async_envd_transport_uses_separate_stack(test_api_key): |
419 | 323 | reset_async_api_transports() |
|
0 commit comments