Skip to content

Commit 1a1f6f0

Browse files
author
Hugo Osvaldo Barrera
committed
Initial async support
Add asyncio to the storage backends and most of the codebase. A lot of it merely uses asyncio APIs, but still doesn't actually run several things concurrently internally. Further improvements will be added on top of these changes Thanks to Thomas Grainger (@graingert) for a few useful pointers related to asyncio.
1 parent 7c9170c commit 1a1f6f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1387
-939
lines changed

.builds/archlinux.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ packages:
1919
- python-pytest-cov
2020
- python-pytest-httpserver
2121
- python-trustme
22+
- python-pytest-asyncio
23+
- python-aiohttp
24+
- python-aiostream
25+
- python-aioresponses
2226
sources:
2327
- https://github.com/pimutils/vdirsyncer
2428
environment:

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ addopts =
88
--cov=vdirsyncer
99
--cov-report=term-missing
1010
--no-cov-on-fail
11+
# filterwarnings=error
1112

1213
[flake8]
1314
application-import-names = tests,vdirsyncer

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
# https://github.com/mitsuhiko/click/issues/200
1414
"click>=5.0,<9.0",
1515
"click-log>=0.3.0, <0.4.0",
16-
# https://github.com/pimutils/vdirsyncer/issues/478
17-
"click-threading>=0.5",
1816
"requests >=2.20.0",
1917
# https://github.com/sigmavirus24/requests-toolbelt/pull/28
2018
# And https://github.com/sigmavirus24/requests-toolbelt/issues/54
2119
"requests_toolbelt >=0.4.0",
2220
# https://github.com/untitaker/python-atomicwrites/commit/4d12f23227b6a944ab1d99c507a69fdbc7c9ed6d # noqa
2321
"atomicwrites>=0.1.7",
22+
"aiohttp>=3.7.1,<4.0.0",
23+
"aiostream>=0.4.3,<0.5.0",
2424
]
2525

2626

test-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ pytest
33
pytest-cov
44
pytest-httpserver
55
trustme
6+
pytest-asyncio
7+
aioresponses

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import os
66

7+
import aiohttp
78
import click_log
89
import pytest
910
from hypothesis import HealthCheck
@@ -52,3 +53,18 @@ def benchmark():
5253
settings.load_profile("ci")
5354
else:
5455
settings.load_profile("dev")
56+
57+
58+
@pytest.fixture
59+
async def aio_session(event_loop):
60+
async with aiohttp.ClientSession() as session:
61+
yield session
62+
63+
64+
@pytest.fixture
65+
async def aio_connector(event_loop):
66+
conn = aiohttp.TCPConnector(limit_per_host=16)
67+
try:
68+
yield conn
69+
finally:
70+
await conn.close()

0 commit comments

Comments
 (0)