2828 )
2929 )
3030 records = []
31- if wait_for_tasks:
32- for response in responses:
33- { {^isSyncClient} }async { {/isSyncClient} }def _func(_: Optional[Event]) -> Event:
34- if response.event_id is None:
35- raise ValueError(
36- "received unexpected response from the push endpoint, eventID must not be undefined"
37- )
38- try:
39- return { {^isSyncClient} }await { {/isSyncClient} }self.get_event(run_id=response.run_id, event_id=response.event_id, request_options=request_options)
40- except RequestException as e:
41- if e.status_code == 404:
42- return None # pyright: ignore
43- raise e
31+ if wait_for_tasks and (len(responses) % 50 == 0 or i == len(objects) - 1) :
32+ for response in responses:
33+ { {^isSyncClient} }async { {/isSyncClient} }def _func(_: Optional[Event]) -> Event:
34+ if response.event_id is None:
35+ raise ValueError(
36+ "received unexpected response from the push endpoint, eventID must not be undefined"
37+ )
38+ try:
39+ return { {^isSyncClient} }await { {/isSyncClient} }self.get_event(run_id=response.run_id, event_id=response.event_id, request_options=request_options)
40+ except RequestException as e:
41+ if e.status_code == 404:
42+ return None # pyright: ignore
43+ raise e
4444
45- _retry_count = 0
45+ _retry_count = 0
4646
47- def _aggregator(_: Event | None) -> None:
48- nonlocal _retry_count
49- _retry_count += 1
47+ def _aggregator(_: Event | None) -> None:
48+ nonlocal _retry_count
49+ _retry_count += 1
5050
51- def _validate(_resp: Event | None) -> bool:
52- return _resp is not None
51+ def _validate(_resp: Event | None) -> bool:
52+ return _resp is not None
5353
54- timeout = RetryTimeout()
54+ timeout = RetryTimeout()
5555
56- { {^isSyncClient} }await { {/isSyncClient} }create_iterable{ {#isSyncClient} }_sync{ {/isSyncClient} }(
57- func=_func,
58- validate=_validate,
59- aggregator=_aggregator,
60- timeout=lambda: timeout(_retry_count),
61- error_validate=lambda _: _retry_count >= 50,
62- error_message=lambda _: f"The maximum number of retries exceeded. (${ _retry_count} /${ 50} )",
63- )
56+ { {^isSyncClient} }await { {/isSyncClient} }create_iterable{ {#isSyncClient} }_sync{ {/isSyncClient} }(
57+ func=_func,
58+ validate=_validate,
59+ aggregator=_aggregator,
60+ timeout=lambda: timeout(_retry_count),
61+ error_validate=lambda _: _retry_count >= 50,
62+ error_message=lambda _: f"The maximum number of retries exceeded. (${ _retry_count} /${ 50} )",
63+ )
6464 return responses
0 commit comments