File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 3
3
Any ,
4
4
Dict ,
5
5
List ,
6
+ Set ,
6
7
Type ,
7
8
)
8
9
17
18
18
19
19
20
class BaseExchangeHandler :
21
+ _exchange_managers : Set [ExchangeManager [Any , Any , Any ]]
22
+
20
23
@property
21
24
@abstractmethod
22
25
def _exchanges (self ) -> Dict [str , Type [BaseExchange [Any , Any , Any ]]]:
23
26
pass
24
27
25
28
def __init__ (self , peer : BasePeer ) -> None :
26
29
self ._peer = peer
30
+ self ._exchange_managers = set ()
27
31
28
32
for attr , exchange_cls in self ._exchanges .items ():
29
33
if hasattr (self , attr ):
@@ -32,9 +36,9 @@ def __init__(self, peer: BasePeer) -> None:
32
36
"present on the class: {1}" .format (attr , getattr (self , attr ))
33
37
)
34
38
manager : ExchangeManager [Any , Any , Any ] = ExchangeManager (self ._peer , peer .cancel_token )
39
+ self ._exchange_managers .add (manager )
35
40
exchange = exchange_cls (manager )
36
41
setattr (self , attr , exchange )
37
42
38
43
def get_stats (self ) -> List [str ]:
39
- manager_attrs = self ._exchanges .keys ()
40
- return [getattr (self , attr ).get_stats () for attr in manager_attrs ]
44
+ return [exchange_manager .get_stats () for exchange_manager in self ._exchange_managers ]
You can’t perform that action at this time.
0 commit comments