Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flush before setting logger labels #352

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading