Skip to content

Commit

Permalink
fix: flush before setting logger labels (#352)
Browse files Browse the repository at this point in the history
* fix: flush before setting logger labels

* hide debug log
  • Loading branch information
chamini2 authored Oct 30, 2024
1 parent a727705 commit 4a4712b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions projects/fal/src/fal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ async def _set_logger_labels(
logger_labels: dict[str, str], channel: async_grpc.Channel
):
try:
import sys

# Flush any prints that were buffered before setting the logger labels
sys.stderr.flush()
sys.stdout.flush()

isolate = definitions.IsolateStub(channel)
isolate_request = definitions.SetMetadataRequest(
# TODO: when submit is shipped, get task_id from an env var
Expand All @@ -77,9 +83,11 @@ async def _set_logger_labels(
)
res = isolate.SetMetadata(isolate_request)
code = await res.code()
assert str(code) == "StatusCode.OK"
assert str(code) == "StatusCode.OK", str(code)
except BaseException:
logger.debug("Failed to set logger labels", exc_info=True)
# NOTE hiding this for now to not print on every request
# logger.debug("Failed to set logger labels", exc_info=True)
pass


def wrap_app(cls: type[App], **kwargs) -> fal.api.IsolatedFunction:
Expand Down

0 comments on commit 4a4712b

Please sign in to comment.