teoat commited on
Commit
fa7464f
·
verified ·
1 Parent(s): a6c0da5

Upload core/messaging.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. core/messaging.py +6 -2
core/messaging.py CHANGED
@@ -22,7 +22,9 @@ class MessageQueueInterface(ABC):
22
  """Publish a message to a topic/queue."""
23
 
24
  @abstractmethod
25
- async def subscribe(self, topic: str, handler: Callable[[dict[str, Any]], None]) -> bool:
 
 
26
  """Subscribe to a topic with a handler function."""
27
 
28
  @abstractmethod
@@ -63,7 +65,9 @@ class InMemoryMessageQueue(MessageQueueInterface):
63
  logger.debug(f"[MQ] Published to {topic}: {message.keys()}")
64
  return True
65
 
66
- async def subscribe(self, topic: str, handler: Callable[[dict[str, Any]], None]) -> bool:
 
 
67
  if topic not in self._subscribers:
68
  self._subscribers[topic] = []
69
  self._subscribers[topic].append(handler)
 
22
  """Publish a message to a topic/queue."""
23
 
24
  @abstractmethod
25
+ async def subscribe(
26
+ self, topic: str, handler: Callable[[dict[str, Any]], None]
27
+ ) -> bool:
28
  """Subscribe to a topic with a handler function."""
29
 
30
  @abstractmethod
 
65
  logger.debug(f"[MQ] Published to {topic}: {message.keys()}")
66
  return True
67
 
68
+ async def subscribe(
69
+ self, topic: str, handler: Callable[[dict[str, Any]], None]
70
+ ) -> bool:
71
  if topic not in self._subscribers:
72
  self._subscribers[topic] = []
73
  self._subscribers[topic].append(handler)