File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 12
12
from . import _tools
13
13
from .. import OpenAI , __version__
14
14
from ._api import register_commands
15
- from ._utils import set_client
15
+ from ._utils import set_client , can_use_http2
16
16
from .._types import ProxiesDict
17
17
from ._errors import CLIError , display_error
18
18
from .._compat import PYDANTIC_V2 , ConfigDict , model_parse
@@ -149,6 +149,7 @@ def _main() -> None:
149
149
150
150
http_client = httpx .Client (
151
151
proxies = proxies or None ,
152
+ http2 = can_use_http2 (),
152
153
)
153
154
154
155
try :
@@ -178,14 +179,12 @@ def _main() -> None:
178
179
)
179
180
else :
180
181
parsed .func ()
181
- except Exception :
182
+ finally :
182
183
try :
183
184
http_client .close ()
184
185
except Exception :
185
186
pass
186
187
187
- raise
188
-
189
188
190
189
if __name__ == "__main__" :
191
190
sys .exit (main ())
Original file line number Diff line number Diff line change @@ -46,3 +46,12 @@ def organization_info() -> str:
46
46
47
47
def print_model (model : BaseModel ) -> None :
48
48
sys .stdout .write (model_json (model , indent = 2 ) + "\n " )
49
+
50
+
51
+ def can_use_http2 () -> bool :
52
+ try :
53
+ import h2 # type: ignore # noqa
54
+ except ImportError :
55
+ return False
56
+
57
+ return True
You can’t perform that action at this time.
0 commit comments