Skip to content

Commit a741477

Browse files
committed
feat: include dank_mids/semaphores in c build
1 parent caafc47 commit a741477

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ benchmark:
1313
poetry run brownie run examples/benchmark
1414

1515
mypyc:
16-
mypyc dank_mids/_demo_mode.py dank_mids/_eth_utils.py dank_mids/_uid.py dank_mids/brownie_patch/__init__.py dank_mids/brownie_patch/_abi.py dank_mids/brownie_patch/call.py dank_mids/brownie_patch/overloaded.py dank_mids/brownie_patch/types.py dank_mids/helpers/_codec.py dank_mids/helpers/lru_cache.py dank_mids/helpers/_weaklist.py dank_mids/constants.py dank_mids/ENVIRONMENT_VARIABLES.py --strict --pretty --disable-error-code unused-ignore
16+
mypyc dank_mids/_demo_mode.py dank_mids/_eth_utils.py dank_mids/_uid.py dank_mids/brownie_patch/__init__.py dank_mids/brownie_patch/_abi.py dank_mids/brownie_patch/call.py dank_mids/brownie_patch/overloaded.py dank_mids/brownie_patch/types.py dank_mids/helpers/_codec.py dank_mids/helpers/lru_cache.py dank_mids/helpers/_weaklist.py dank_mids/constants.py dank_mids/ENVIRONMENT_VARIABLES.py dank_mids/semaphores.py --strict --pretty --disable-error-code unused-ignore
1717

1818
mypyc-3-8:
19-
mypyc dank_mids/_demo_mode.py dank_mids/_eth_utils.py dank_mids/_uid.py dank_mids/brownie_patch/__init__.py dank_mids/brownie_patch/_abi.py dank_mids/brownie_patch/call.py dank_mids/brownie_patch/overloaded.py dank_mids/brownie_patch/types.py dank_mids/helpers/_codec.py dank_mids/helpers/_weaklist.py dank_mids/constants.py dank_mids/ENVIRONMENT_VARIABLES.py --strict --pretty --disable-error-code unused-ignore
19+
mypyc dank_mids/_demo_mode.py dank_mids/_eth_utils.py dank_mids/_uid.py dank_mids/brownie_patch/__init__.py dank_mids/brownie_patch/_abi.py dank_mids/brownie_patch/call.py dank_mids/brownie_patch/overloaded.py dank_mids/brownie_patch/types.py dank_mids/helpers/_codec.py dank_mids/helpers/_weaklist.py dank_mids/constants.py dank_mids/ENVIRONMENT_VARIABLES.py dank_mids/semaphores.py --strict --pretty --disable-error-code unused-ignore
2020

dank_mids/semaphores.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
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
33

44
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
67
from a_sync.primitives.locks.prio_semaphore import (
78
_AbstractPrioritySemaphore,
89
_PrioritySemaphoreContextManager,
@@ -38,7 +39,7 @@ def __init__(
3839
super().__init__(parent, priority, name)
3940

4041

41-
_TOP_PRIORITY = -1
42+
_TOP_PRIORITY: Final = -1
4243

4344

4445
# NOTE: keep this so we can include in type stubs
@@ -92,13 +93,13 @@ def __init__(self, controller: "DankMiddlewareController") -> None:
9293
from dank_mids import ENVIRONMENT_VARIABLES
9394
from dank_mids._requests import RPCRequest
9495

95-
self.controller = controller
96+
self.controller: Final = controller
9697
"""
9798
A reference to the DankMiddlewareController instance that this _MethodQueues is associated with.
9899
"""
99100

100-
self.method_queues = {
101-
method: a_sync.SmartProcessingQueue(
101+
self.method_queues: Final = {
102+
method: SmartProcessingQueue(
102103
RPCRequest, num_workers=sem._value, name=f"{method} {controller}"
103104
)
104105
for method, sem in ENVIRONMENT_VARIABLES.method_semaphores.items()
@@ -109,14 +110,14 @@ def __init__(self, controller: "DankMiddlewareController") -> None:
109110
These queues are used to manage and process requests for different RPC methods.
110111
"""
111112

112-
self.keys = self.method_queues.keys()
113+
self.keys: Final = tuple(self.method_queues.keys())
113114
"""
114115
A view of the keys (RPC method names) in the method_queues dictionary.
115116
This allows for efficient iteration over the available method names.
116117
"""
117118

118119
@lru_cache_lite
119-
def __getitem__(self, method: RPCEndpoint) -> Optional[a_sync.SmartProcessingQueue]:
120+
def __getitem__(self, method: RPCEndpoint) -> Optional[SmartProcessingQueue]:
120121
"""
121122
Retrieves the queue for a given RPC method.
122123

0 commit comments

Comments
 (0)