5757
5858Each call uses a short-lived ``httpx.Client``; no global state.
5959"""
60+
6061from __future__ import annotations
6162
6263import json
@@ -97,8 +98,7 @@ def __init__(
9798 ) -> None :
9899 if httpx is None and client is None :
99100 raise ImportError (
100- "AsyncHttpRunner requires httpx. Install with "
101- "`pip install core-runner[http]`"
101+ "AsyncHttpRunner requires httpx. Install with `pip install core-runner[http]`"
102102 )
103103 self ._follow_redirects = follow_redirects
104104 self ._verify = verify
@@ -137,12 +137,11 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
137137
138138 pending_raw = meta .get ("http.poll_pending_codes" ) or ""
139139 try :
140- pending_codes = tuple (
141- int (s .strip ()) for s in pending_raw .split ("," ) if s .strip ()
142- )
140+ pending_codes = tuple (int (s .strip ()) for s in pending_raw .split ("," ) if s .strip ())
143141 except ValueError :
144142 return _rejected (
145- invocation , started ,
143+ invocation ,
144+ started ,
146145 "http.poll_pending_codes must be comma-separated integers" ,
147146 )
148147
@@ -187,18 +186,22 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
187186 # - server acknowledged async dispatch (status field absent
188187 # or non-terminal, e.g. Archon's {accepted, status:"started"})
189188 if _is_synchronous_terminal (
190- kickoff_resp , poll_status_path , terminal_states ,
189+ kickoff_resp ,
190+ poll_status_path ,
191+ terminal_states ,
191192 ):
192193 return _terminal_from_kickoff (
193- invocation , started , kickoff_resp ,
194- success_states , poll_status_path ,
194+ invocation ,
195+ started ,
196+ kickoff_resp ,
197+ success_states ,
198+ poll_status_path ,
195199 )
196200 # Fall through to poll loop — kickoff was an ack, not a result.
197201 elif kickoff_resp .status_code != 202 :
198202 preview = kickoff_resp .text [:200 ] if kickoff_resp .text else ""
199203 msg = (
200- f"kickoff expected 202 (or 200), got HTTP "
201- f"{ kickoff_resp .status_code } : { preview } "
204+ f"kickoff expected 202 (or 200), got HTTP { kickoff_resp .status_code } : { preview } "
202205 ).strip ()
203206 return _failed (invocation , started , msg )
204207
@@ -208,7 +211,8 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
208211 run_id_path = meta .get ("http.poll_run_id_path" )
209212 if not run_id_path :
210213 return _rejected (
211- invocation , started ,
214+ invocation ,
215+ started ,
212216 "poll_url_template contains {run_id} but no poll_run_id_path provided" ,
213217 )
214218 try :
@@ -228,7 +232,9 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
228232 while True :
229233 if _deadline_exceeded (deadline_monotonic ):
230234 return _timed_out (
231- invocation , started , timeout ,
235+ invocation ,
236+ started ,
237+ timeout ,
232238 TimeoutError ("poll loop deadline exceeded" ),
233239 "poll" ,
234240 )
@@ -249,7 +255,8 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
249255 continue
250256 preview = poll_resp .text [:200 ] if poll_resp .text else ""
251257 return _failed (
252- invocation , started ,
258+ invocation ,
259+ started ,
253260 f"poll expected HTTP 200, got { poll_resp .status_code } : { preview } " .strip (),
254261 )
255262 try :
@@ -260,8 +267,7 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
260267 status = _extract_path (poll_payload , poll_status_path )
261268 if status is None :
262269 msg = (
263- f"poll response has no field at path "
264- f"{ poll_status_path !r} : { poll_payload !r} "
270+ f"poll response has no field at path { poll_status_path !r} : { poll_payload !r} "
265271 )
266272 return _failed (invocation , started , msg )
267273 status_str = str (status )
@@ -280,8 +286,7 @@ def run(self, invocation: RuntimeInvocation) -> RuntimeResult:
280286 stderr_path = None ,
281287 artifacts = [],
282288 error_summary = (
283- None if success
284- else f"backend reported terminal status: { status_str } "
289+ None if success else f"backend reported terminal status: { status_str } "
285290 ),
286291 )
287292
@@ -454,9 +459,7 @@ def _timed_out(
454459 phase : str ,
455460) -> RuntimeResult :
456461 note = (
457- f"{ phase } exceeded timeout of { timeout } s: { exc } "
458- if timeout
459- else f"{ phase } timed out: { exc } "
462+ f"{ phase } exceeded timeout of { timeout } s: { exc } " if timeout else f"{ phase } timed out: { exc } "
460463 )
461464 return RuntimeResult (
462465 invocation_id = invocation .invocation_id ,
0 commit comments