Skip to content

Commit b806f14

Browse files
committed
fix(deprecation): iscoroutinefunction from inspect
1 parent 9d6aeab commit b806f14

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/flare_ai_kit/consensus/communication/channels.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Implementation of communication channels for inter-agent communication."""
22

33
import asyncio
4+
import inspect
45
import time
56
import uuid
67
from collections import defaultdict
@@ -89,7 +90,7 @@ async def publish_event(self, event_type: str, data: dict[str, Any]) -> None:
8990
if handlers:
9091
tasks: list[Any] = []
9192
for handler in handlers.values():
92-
if asyncio.iscoroutinefunction(handler):
93+
if inspect.iscoroutinefunction(handler):
9394
tasks.append(handler(data))
9495
else:
9596
# For non-async handlers, run in thread pool

src/flare_ai_kit/consensus/coordinator/simple.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""An enhanced implementation of the Coordinator interface."""
22

33
import asyncio
4+
import inspect
45
from dataclasses import dataclass, field
56
from typing import Any
67

@@ -74,14 +75,14 @@ async def start_agents(self) -> None:
7475
"""Starts all agents that define a `start()` coroutine."""
7576
for agent in self.agents.values():
7677
agent_start = getattr(agent.agent, "start", None)
77-
if agent_start is not None and asyncio.iscoroutinefunction(agent_start):
78+
if agent_start is not None and inspect.iscoroutinefunction(agent_start):
7879
await agent_start()
7980

8081
async def stop_agents(self) -> None:
8182
"""Stops all agents that define a `stop()` coroutine."""
8283
for agent in self.agents.values():
8384
agent_stop = getattr(agent.agent, "stop", None)
84-
if agent_stop is not None and asyncio.iscoroutinefunction(agent_stop):
85+
if agent_stop is not None and inspect.iscoroutinefunction(agent_stop):
8586
await agent_stop()
8687

8788
def monitor_agents(self) -> list[dict[str, str | Any]]:

0 commit comments

Comments
 (0)