Skip to content

Commit 674cdf2

Browse files
authored
Avoid printing too many messages in Oscar (mars-project#2871)
1 parent 4ad5491 commit 674cdf2

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

mars/oscar/backends/context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ async def send(
175175
profiling_context=profiling_context,
176176
)
177177

178+
# use `%.500` to avoid print too long messages
178179
with debug_async_timeout(
179180
"actor_call_timeout",
180-
"Calling %r on %s at %s timed out",
181+
"Calling %.500r on %s at %s timed out",
181182
message.content,
182183
actor_ref.uid,
183184
actor_ref.address,

mars/oscar/backends/pool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,10 @@ async def process_message(self, message: _MessageBase, channel: Channel):
339339
with _ErrorProcessor(
340340
self.external_address, message.message_id, message.protocol
341341
) as processor:
342+
# use `%.500` to avoid print too long messages
342343
with debug_async_timeout(
343344
"process_message_timeout",
344-
"Process message %s of channel %s timeout.",
345+
"Process message %.500s of channel %s timeout.",
345346
message,
346347
channel,
347348
):

mars/oscar/backends/ray/communication.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ async def recv(self):
203203
try:
204204
# Wait on ray object ref
205205
message, object_ref = await self._in_queue.get()
206+
# use `%.500` to avoid print too long messages
206207
with debug_async_timeout(
207-
"ray_object_retrieval_timeout", "Client sent message is %s", message
208+
"ray_object_retrieval_timeout", "Client sent message is %.500s", message
208209
):
209210
result = await object_ref
210211
if isinstance(result, RayChannelException):

mars/oscar/core.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,8 @@ cdef class _BaseActor:
501501
except Exception as ex:
502502
if _log_unhandled_errors:
503503
from .debug import logger as debug_logger
504-
debug_logger.exception('Got unhandled error when handling message %r '
504+
# use `%.500` to avoid print too long messages
505+
debug_logger.exception('Got unhandled error when handling message %.500r '
505506
'in actor %s at %s', message, self.uid, self.address)
506507
raise ex
507508

0 commit comments

Comments
 (0)