Skip to content

Commit d42e3ce

Browse files
committed
Only log any error that happens during log redirection.
1 parent be7bba0 commit d42e3ce

3 files changed

Lines changed: 59 additions & 56 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ classifiers = [
2525
keywords = ["apify", "api", "client", "automation", "crawling", "scraping"]
2626
dependencies = [
2727
"colorama>=0.4.0",
28-
"impit>=0.9.2",
28+
"impit~=0.9.2",
2929
"more_itertools>=10.0.0",
3030
"pydantic[email]>=2.11.0",
3131
]

src/apify_client/_streamed_log.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,15 @@ async def __aexit__(
215215
await self.stop()
216216

217217
async def _stream_log(self) -> None:
218-
async with self._log_client.stream(raw=True) as log_stream:
219-
if not log_stream:
220-
return
221-
try:
222-
async for data in log_stream.aiter_bytes():
223-
self._process_new_data(data)
224-
finally:
225-
# Flush the last buffered part even if the task is cancelled by `stop()`.
226-
self._log_buffer_content(include_last_part=True)
218+
try:
219+
async with self._log_client.stream(raw=True) as log_stream:
220+
if not log_stream:
221+
return
222+
try:
223+
async for data in log_stream.aiter_bytes():
224+
self._process_new_data(data)
225+
finally:
226+
# Flush the last buffered part even if the task is cancelled by `stop()`.
227+
self._log_buffer_content(include_last_part=True)
228+
except Exception:
229+
self._to_logger.exception('Log redirection stoped due to unexpected error:')

0 commit comments

Comments
 (0)