Skip to content

Commit

Permalink
log traceback properly (#1734)
Browse files Browse the repository at this point in the history
* log traceback correctly
* use repr(exception) instead of str(exception) if str(exception) is blank

---------

Signed-off-by: technillogue <[email protected]>
  • Loading branch information
technillogue committed Jun 19, 2024
1 parent 6d9bbc0 commit c6b5886
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/cog/server/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ def _handle_predict_error(self, id: str) -> Iterator[None]:
except asyncio.CancelledError:
done.canceled = True
except Exception as e:
traceback.print_exc()
tb = traceback.format_exc()
self._log(tb)
done.error = True
done.error_detail = str(e)
done.error_detail = str(e) if str(e) else repr(e)
finally:
self.prediction_id_context.reset(token)
self._cancelable = False
Expand Down Expand Up @@ -313,7 +314,7 @@ def _stream_write_hook(
original_stream.write(data)
original_stream.flush()
# this won't work, this fn gets called from a thread, not the async task
self._log(data, stream_name)
self._log(data, source=stream_name)


def get_loop() -> asyncio.AbstractEventLoop:
Expand Down

0 comments on commit c6b5886

Please sign in to comment.