1
1
from decimal import Decimal
2
- from typing import TYPE_CHECKING , Literal , Optional , Type , Union
2
+ from typing import TYPE_CHECKING , Final , Literal , Optional , Type , Union
3
3
4
4
import a_sync
5
- from a_sync .primitives import DummySemaphore , ThreadsafeSemaphore
5
+ from a_sync import SmartProcessingQueue , ThreadsafeSemaphore
6
+ from a_sync .primitives import DummySemaphore
6
7
from a_sync .primitives .locks .prio_semaphore import (
7
8
_AbstractPrioritySemaphore ,
8
9
_PrioritySemaphoreContextManager ,
@@ -38,7 +39,7 @@ def __init__(
38
39
super ().__init__ (parent , priority , name )
39
40
40
41
41
- _TOP_PRIORITY = - 1
42
+ _TOP_PRIORITY : Final = - 1
42
43
43
44
44
45
# NOTE: keep this so we can include in type stubs
@@ -92,13 +93,13 @@ def __init__(self, controller: "DankMiddlewareController") -> None:
92
93
from dank_mids import ENVIRONMENT_VARIABLES
93
94
from dank_mids ._requests import RPCRequest
94
95
95
- self .controller = controller
96
+ self .controller : Final = controller
96
97
"""
97
98
A reference to the DankMiddlewareController instance that this _MethodQueues is associated with.
98
99
"""
99
100
100
- self .method_queues = {
101
- method : a_sync . SmartProcessingQueue (
101
+ self .method_queues : Final = {
102
+ method : SmartProcessingQueue (
102
103
RPCRequest , num_workers = sem ._value , name = f"{ method } { controller } "
103
104
)
104
105
for method , sem in ENVIRONMENT_VARIABLES .method_semaphores .items ()
@@ -109,14 +110,14 @@ def __init__(self, controller: "DankMiddlewareController") -> None:
109
110
These queues are used to manage and process requests for different RPC methods.
110
111
"""
111
112
112
- self .keys = self .method_queues .keys ()
113
+ self .keys : Final = tuple ( self .method_queues .keys () )
113
114
"""
114
115
A view of the keys (RPC method names) in the method_queues dictionary.
115
116
This allows for efficient iteration over the available method names.
116
117
"""
117
118
118
119
@lru_cache_lite
119
- def __getitem__ (self , method : RPCEndpoint ) -> Optional [a_sync . SmartProcessingQueue ]:
120
+ def __getitem__ (self , method : RPCEndpoint ) -> Optional [SmartProcessingQueue ]:
120
121
"""
121
122
Retrieves the queue for a given RPC method.
122
123
0 commit comments