@@ -132,20 +132,22 @@ def __init__(
132
132
max_concurrent_connections if max_concurrent_connections is not None else global_max_concurrent_connections
133
133
)
134
134
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 :
139
140
self ._chia_pause ()
140
141
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 } " )
144
146
if (
145
- self . _active_count > 0
147
+ active_connections > 0
146
148
and self ._sockets is not None
147
149
and self ._paused
148
- and self . _active_count < self .max_concurrent_connections
150
+ and active_connections < self .max_concurrent_connections
149
151
):
150
152
self ._chia_resume ()
151
153
@@ -180,6 +182,12 @@ def _chia_resume(self) -> None:
180
182
)
181
183
logging .getLogger (__name__ ).debug ("Resumed accepting connections." )
182
184
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
+
183
191
184
192
async def _chia_create_server (
185
193
cls : Any ,
0 commit comments