Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Open
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 panini/middleware/debug_middleware.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

from panini.middleware import Middleware
from panini.utils.logger import get_logger

Expand Down Expand Up @@ -32,10 +34,16 @@ async def send_any(self, subject: str, message, send_func, *args, **kwargs):

async def listen_any(self, msg, callback):
if not self.use_listen_any:
return await callback(msg)
if asyncio.iscoroutinefunction(callback):
return await callback(msg)
else:
return callback(msg)

self._log(f"Listen to {msg.subject} with payload {msg.data}")
response = await callback(msg)
if asyncio.iscoroutinefunction(callback):
response = await callback(msg)
else:
response = callback(msg)
if response is not None:
self._log(f"Answered to it: {response}")

Expand Down