Skip to content

Commit 238ae01

Browse files
committed
fixup
1 parent ec0df86 commit 238ae01

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

chia/server/chia_policy.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,22 @@ def __init__(
132132
max_concurrent_connections if max_concurrent_connections is not None else global_max_concurrent_connections
133133
)
134134

135-
def _attach(self) -> None:
136-
super()._attach()
137-
logging.getLogger(__name__).debug(f"New connection. Total connections: {self._active_count}")
138-
if not self._paused and self._active_count >= self.max_concurrent_connections:
135+
def _attach(self, *args: object, **kwargs: object) -> None:
136+
super()._attach(*args, **kwargs)
137+
active_connections = self._chia_active_connections()
138+
logging.getLogger(__name__).debug(f"New connection. Total connections: {active_connections}")
139+
if not self._paused and active_connections >= self.max_concurrent_connections:
139140
self._chia_pause()
140141

141-
def _detach(self) -> None:
142-
super()._detach()
143-
logging.getLogger(__name__).debug(f"Connection lost. Total connections: {self._active_count}")
142+
def _detach(self, *args: object, **kwargs: object) -> None:
143+
super()._detach(*args, **kwargs)
144+
active_connections = self._chia_active_connections()
145+
logging.getLogger(__name__).debug(f"Connection lost. Total connections: {active_connections}")
144146
if (
145-
self._active_count > 0
147+
active_connections > 0
146148
and self._sockets is not None
147149
and self._paused
148-
and self._active_count < self.max_concurrent_connections
150+
and active_connections < self.max_concurrent_connections
149151
):
150152
self._chia_resume()
151153

@@ -180,6 +182,12 @@ def _chia_resume(self) -> None:
180182
)
181183
logging.getLogger(__name__).debug("Resumed accepting connections.")
182184

185+
def _chia_active_connections(self) -> int:
186+
if sys.version_info >= (3, 13):
187+
return len(self._clients)
188+
else:
189+
return self._active_count
190+
183191

184192
async def _chia_create_server(
185193
cls: Any,

0 commit comments

Comments
 (0)