Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions python/restate/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"""This module contains the ASGI server for the restate framework."""

import asyncio
import logging
from typing import Dict, TypedDict, Literal
import traceback

from restate.discovery import compute_discovery_json
from restate.endpoint import Endpoint
Expand All @@ -24,6 +24,8 @@
from restate._internal import PyIdentityVerifier, IdentityVerificationException # pylint: disable=import-error,no-name-in-module
from restate._internal import SDK_VERSION # pylint: disable=import-error,no-name-in-module

logger = logging.getLogger(__name__)

X_RESTATE_SERVER = header_to_binary([("x-restate-server", f"restate-sdk-python/{SDK_VERSION}")])


Expand Down Expand Up @@ -165,7 +167,7 @@ async def process_invocation_to_completion(
return
# pylint: disable=W0718
except Exception:
traceback.print_exc()
logger.exception("Exception in Restate handler")
try:
await context.leave()
finally:
Expand Down Expand Up @@ -272,7 +274,7 @@ async def app(scope: Scope, receive: Receive, send: Send):
except LifeSpanNotImplemented as e:
raise e
except Exception as e:
traceback.print_exc()
logger.exception("Exception in ASGI app")
raise e

if is_running_on_lambda():
Expand Down
8 changes: 4 additions & 4 deletions python/restate/server_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from datetime import timedelta
import inspect
import functools
import logging
from typing import Any, Awaitable, Callable, Dict, List, Optional, TypeVar, Union, Coroutine
import typing
import traceback
Expand Down Expand Up @@ -59,6 +60,7 @@
DoWaitPendingRun,
)

logger = logging.getLogger(__name__)

T = TypeVar("T")
I = TypeVar("I")
Expand Down Expand Up @@ -448,8 +450,7 @@ async def must_take_notification(self, handle):
if isinstance(res, Exception):
# We might need to write out something at this point.
await self.take_and_send_output()
# Print this exception, might be relevant for the user
traceback.print_exception(res)
logger.exception("Exception in take_notification", exc_info=res)
raise SdkInternalException() from res
if isinstance(res, Suspended):
# We might need to write out something at this point.
Expand All @@ -469,8 +470,7 @@ async def create_poll_or_cancel_coroutine(self, handles: typing.List[int]) -> No
await self.take_and_send_output()
do_progress_response = self.vm.do_progress(handles)
if isinstance(do_progress_response, BaseException):
# Print this exception, might be relevant for the user
traceback.print_exception(do_progress_response)
logger.exception("Exception in do_progress", exc_info=do_progress_response)
raise SdkInternalException() from do_progress_response
if isinstance(do_progress_response, Suspended):
raise SuspendedException()
Expand Down