|
1 | 1 | import socket
|
2 | 2 | from contextlib import contextmanager
|
3 | 3 | import time
|
| 4 | +import threading |
| 5 | +import traceback |
4 | 6 |
|
5 | 7 | from medcat.components.addons.meta_cat import meta_cat
|
6 | 8 | from medcat.storage.serialisers import serialise, deserialise
|
@@ -81,11 +83,33 @@ def tearDownClass(cls):
|
81 | 83 | cls.temp_dir.cleanup()
|
82 | 84 |
|
83 | 85 | def test_no_network_load(self):
|
| 86 | + import threading |
| 87 | + import sys |
| 88 | + import os |
| 89 | + |
| 90 | + print("=== DEBUG: Environment ===") |
| 91 | + print(f"CI: {os.getenv('CI')}") |
| 92 | + print(f"GITHUB_ACTIONS: {os.getenv('GITHUB_ACTIONS')}") |
| 93 | + print(f"Python version: {sys.version}") |
| 94 | + print(f"Transformers version: {transformers.__version__}") |
| 95 | + print(f"Initial thread count: {threading.active_count()}") |
| 96 | + print(f"Initial threads: {[t.name for t in threading.enumerate()]}") |
| 97 | + |
84 | 98 | with assert_tries_network():
|
85 | 99 | with force_hf_download():
|
| 100 | + print("=== DEBUG: Before deserialise ===") |
| 101 | + print(f"Thread count: {threading.active_count()}") |
86 | 102 | mc = deserialise(self.mc_save_path)
|
87 | 103 | # NOTE: the network calls are done async
|
88 | 104 | # and as such we may need to wait for them
|
89 | 105 | # to be done before we exit the context managers,
|
90 |
| - time.sleep(1.0) |
| 106 | + print(f"=== DEBUG: After deserialise ===") |
| 107 | + print(f"Thread count: {threading.active_count()}") |
| 108 | + print(f"Current threads: {[t.name for t in threading.enumerate()]}") |
| 109 | + wait_time = 5.0 if os.getenv('CI') else 1.0 |
| 110 | + print(f"=== DEBUG: Waiting {wait_time}s for background threads ===") |
| 111 | + time.sleep(wait_time) |
| 112 | + print("=== DEBUG: After wait ===") |
| 113 | + print(f"Thread count: {threading.active_count()}") |
| 114 | + |
91 | 115 | self.assertIsInstance(mc, meta_cat.MetaCATAddon)
|
0 commit comments