Skip to content

Commit 6438f3c

Browse files
committed
Improve async client to use recv_task for response tracking
1 parent 3b8b471 commit 6438f3c

12 files changed

Lines changed: 49 additions & 37 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ setup:
99
)
1010

1111
test:
12-
python3 -m pytest tests --cov=zero --cov-report=term-missing --cov-config=.coveragerc -vv --durations=10 --timeout=280 -s --exitfirst
12+
python3 -m pytest tests --cov=zero --cov-report=term-missing --cov-config=.coveragerc -vv --durations=10 --timeout=280
1313

1414
docker-test:
1515
docker build -t zero-test -f Dockerfile.test .

benchmarks/local/zero/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim
1+
FROM python:3.13-slim
22

33
COPY requirements.txt requirements.txt
44
RUN pip install -r requirements.txt

benchmarks/local/zero/docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ services:
1616
# gateway:
1717
# build: .
1818
# container_name: gateway
19-
# command: gunicorn gateway_aiohttp:app --bind 0.0.0.0:8000 --worker-class aiohttp.worker.GunicornWebWorker --workers 8 --log-level warning
19+
# command: gunicorn gateway_aiohttp:app --bind 0.0.0.0:8766 --worker-class aiohttp.worker.GunicornWebWorker --workers 8 --log-level warning
2020
# ports:
21-
# - "8000:8000"
21+
# - "8766:8766"
2222
# depends_on:
2323
# - server
2424
# - redis

benchmarks/others/zero_publisher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from benchmarks.async_redis_repository import save_order as saveOrder
66
from benchmarks.model import CreateOrderReq, Order, OrderResp, OrderStatus
7-
87
from zero import ZeroSubscriber
98

109

requirements-lint.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ flake8
44
pylint
55
pytype
66
mypy
7-
pydantic
7+
pydantic
8+
uvloop

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@
2424
install_requires=["pyzmq", "msgspec"],
2525
extras_require={
2626
"pydantic": ["pydantic"], # Optional dependency
27+
"uvloop": ["uvloop"], # Optional dependency for better performance
28+
"all": ["pydantic", "uvloop"], # Install all optional dependencies
2729
},
2830
)

tests/concurrency/rps_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_and_sum(msg):
1818

1919

2020
if __name__ == "__main__":
21-
process_no = 32
21+
process_no = 8
2222
pool = Pool(process_no)
2323

2424
sum_items = []

zero/codegen/codegen.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
)
2121

2222
import msgspec
23-
from pydantic import BaseModel
2423

2524
from zero.utils.type_util import typing_types
2625

26+
try:
27+
from pydantic import BaseModel
28+
29+
PYDANTIC_AVAILABLE = True
30+
except ImportError:
31+
PYDANTIC_AVAILABLE = False
32+
2733
python_version = sys.version_info
2834

2935

@@ -217,16 +223,14 @@ def _generate_code_for_type(self, typ: Type, already_generated: Set[Type]) -> st
217223
for possible_typ in all_possible_typs:
218224
self._track_imports(possible_typ)
219225
if isinstance(possible_typ, type) and (
220-
issubclass( # pytype: disable=wrong-arg-types
221-
possible_typ,
222-
(
223-
msgspec.Struct,
224-
BaseModel,
225-
enum.Enum,
226-
enum.IntEnum,
227-
),
228-
)
226+
issubclass(possible_typ, (msgspec.Struct, enum.Enum, enum.IntEnum))
229227
or is_dataclass(possible_typ)
228+
or (
229+
PYDANTIC_AVAILABLE
230+
and issubclass( # pytype: disable=wrong-arg-types
231+
possible_typ, BaseModel
232+
)
233+
)
230234
):
231235
code += self._generate_class_code(possible_typ, already_generated)
232236
return code

zero/protocols/zeromq/server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
from .worker import _Worker
1717

18-
# import uvloop
19-
2018

2119
class ZMQServer:
2220
def __init__(

zero/rpc/server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
if TYPE_CHECKING: # pragma: no cover
2222
from .protocols import ZeroServerProtocol
2323

24-
# import uvloop
25-
2624

2725
class ZeroServer:
2826
def __init__(

0 commit comments

Comments
 (0)