Skip to content

Commit f403bdc

Browse files
committed
chore(node): remove async gather
1 parent fa35932 commit f403bdc

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

app/node/__init__.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import asyncio
2-
31
from PasarGuardNodeBridge import PasarGuardNode, create_node, Health, NodeType
42
from aiorwlock import RWLock
53

@@ -90,25 +88,24 @@ async def get_not_connected_nodes(self) -> list[tuple[int, PasarGuardNode]]:
9088
]
9189
return nodes
9290

93-
async def update_user(self, user: UserResponse, inbounds: list[str] = None):
94-
proto_user = serialize_user_for_node(user.id, user.username, user.proxy_settings.dict(), inbounds)
95-
96-
async with self._lock.reader_lock:
97-
add_tasks = [node.update_user(proto_user) for node in self._nodes.values()]
98-
await asyncio.gather(*add_tasks, return_exceptions=True)
99-
10091
async def update_users(self, users: list[User]):
10192
proto_users = await serialize_users_for_node(users)
10293
async with self._lock.reader_lock:
103-
add_tasks = [node.update_users(proto_users) for node in self._nodes.values()]
104-
await asyncio.gather(*add_tasks, return_exceptions=True)
94+
for node in self._nodes.values():
95+
node.update_users(proto_users)
96+
97+
async def _update_user(self, user):
98+
async with self._lock.reader_lock:
99+
for node in self._nodes.values():
100+
node.update_user(user)
101+
102+
async def update_user(self, user: UserResponse, inbounds: list[str] = None):
103+
proto_user = serialize_user_for_node(user.id, user.username, user.proxy_settings.dict(), inbounds)
104+
await self._update_user(proto_user)
105105

106106
async def remove_user(self, user: UserResponse):
107107
proto_user = serialize_user_for_node(user.id, user.username, user.proxy_settings.dict())
108-
109-
async with self._lock.reader_lock:
110-
remove_tasks = [node.update_user(proto_user) for node in self._nodes.values()]
111-
await asyncio.gather(*remove_tasks, return_exceptions=True)
108+
await self._update_user(proto_user)
112109

113110

114111
node_manager: NodeManager = NodeManager()

0 commit comments

Comments
 (0)