Skip to content

Commit

Permalink
uvloop is optional; defaults to asyncio (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
fullerzz authored Nov 24, 2023
1 parent 35d3aad commit b6355f6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 43 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ The package is available via pip. (Soon)
pip install zconcurrent
```

If you're not on Windows, install the uvloop extra to increase performance.

```bash
pip install "zconcurrent[uvloop]"
```

## Usage

The package can be imported as shown:
Expand Down
13 changes: 8 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ description = ""
authors = ["Zach Fuller <[email protected]>"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/fullerzz/zConcurrent"
packages = [{include = "zconcurrent", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
aiohttp = "~3.8.6"
aiodns = "~3.1.1"
msgspec = "0.18.4"
uvloop = "0.19.0"
uvloop = { version = "0.19.0", optional = true }

[tool.poetry.group.dev.dependencies]
ruff = "~0.1.4"
pre-commit = "3.5.0"
pytest = "^7.4.3"
pytest-asyncio = "^0.21.1"

[tool.poetry.extras]
uvloop = ["uvloop"]

[tool.ruff]
exclude = [
".bzr",
Expand Down
38 changes: 3 additions & 35 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ frozenlist==1.4.0 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:f0ed05f5079c708fe74bf9027e95125334b6978bf07fd5ab923e9e55e5fbb9d3 \
--hash=sha256:f61e2dc5ad442c52b4887f1fdc112f97caeff4d9e6ebe78879364ac59f1663e1 \
--hash=sha256:fec520865f42e5c7f050c2a79038897b1c7d1595e907a9e08e3353293ffc948e
idna==3.4 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \
--hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2
idna==3.5 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:27009fe2735bf8723353582d48575b23c533cc2c2de7b5a68908d91b5eb18d08 \
--hash=sha256:79b8f0ac92d2351be5f6122356c9a592c96d81c9a79e4b488bf2a6a15f88057a
msgspec==0.18.4 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:227fee75a25080a8b3677cdd95b9c0c3652e27869004a084886c65eb558b3dd6 \
--hash=sha256:241277eed9fd91037372519fca62aecf823f7229c1d351030d0be5e3302580c1 \
Expand Down Expand Up @@ -474,38 +474,6 @@ pycares==4.4.0 ; python_version >= "3.10" and python_version < "4.0" \
pycparser==2.21 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9 \
--hash=sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206
uvloop==0.19.0 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:0246f4fd1bf2bf702e06b0d45ee91677ee5c31242f39aab4ea6fe0c51aedd0fd \
--hash=sha256:02506dc23a5d90e04d4f65c7791e65cf44bd91b37f24cfc3ef6cf2aff05dc7ec \
--hash=sha256:13dfdf492af0aa0a0edf66807d2b465607d11c4fa48f4a1fd41cbea5b18e8e8b \
--hash=sha256:2693049be9d36fef81741fddb3f441673ba12a34a704e7b4361efb75cf30befc \
--hash=sha256:271718e26b3e17906b28b67314c45d19106112067205119dddbd834c2b7ce797 \
--hash=sha256:2df95fca285a9f5bfe730e51945ffe2fa71ccbfdde3b0da5772b4ee4f2e770d5 \
--hash=sha256:31e672bb38b45abc4f26e273be83b72a0d28d074d5b370fc4dcf4c4eb15417d2 \
--hash=sha256:34175c9fd2a4bc3adc1380e1261f60306344e3407c20a4d684fd5f3be010fa3d \
--hash=sha256:45bf4c24c19fb8a50902ae37c5de50da81de4922af65baf760f7c0c42e1088be \
--hash=sha256:472d61143059c84947aa8bb74eabbace30d577a03a1805b77933d6bd13ddebbd \
--hash=sha256:47bf3e9312f63684efe283f7342afb414eea4d3011542155c7e625cd799c3b12 \
--hash=sha256:492e2c32c2af3f971473bc22f086513cedfc66a130756145a931a90c3958cb17 \
--hash=sha256:4ce6b0af8f2729a02a5d1575feacb2a94fc7b2e983868b009d51c9a9d2149bef \
--hash=sha256:5138821e40b0c3e6c9478643b4660bd44372ae1e16a322b8fc07478f92684e24 \
--hash=sha256:5588bd21cf1fcf06bded085f37e43ce0e00424197e7c10e77afd4bbefffef428 \
--hash=sha256:570fc0ed613883d8d30ee40397b79207eedd2624891692471808a95069a007c1 \
--hash=sha256:5a05128d315e2912791de6088c34136bfcdd0c7cbc1cf85fd6fd1bb321b7c849 \
--hash=sha256:5daa304d2161d2918fa9a17d5635099a2f78ae5b5960e742b2fcfbb7aefaa593 \
--hash=sha256:5f17766fb6da94135526273080f3455a112f82570b2ee5daa64d682387fe0dcd \
--hash=sha256:6e3d4e85ac060e2342ff85e90d0c04157acb210b9ce508e784a944f852a40e67 \
--hash=sha256:7010271303961c6f0fe37731004335401eb9075a12680738731e9c92ddd96ad6 \
--hash=sha256:7207272c9520203fea9b93843bb775d03e1cf88a80a936ce760f60bb5add92f3 \
--hash=sha256:78ab247f0b5671cc887c31d33f9b3abfb88d2614b84e4303f1a63b46c046c8bd \
--hash=sha256:7b1fd71c3843327f3bbc3237bedcdb6504fd50368ab3e04d0410e52ec293f5b8 \
--hash=sha256:8ca4956c9ab567d87d59d49fa3704cf29e37109ad348f2d5223c9bf761a332e7 \
--hash=sha256:91ab01c6cd00e39cde50173ba4ec68a1e578fee9279ba64f5221810a9e786533 \
--hash=sha256:cd81bdc2b8219cb4b2556eea39d2e36bfa375a2dd021404f90a62e44efaaf957 \
--hash=sha256:da8435a3bd498419ee8c13c34b89b5005130a476bda1d6ca8cfdde3de35cd650 \
--hash=sha256:de4313d7f575474c8f5a12e163f6d89c0a878bc49219641d49e6f1444369a90e \
--hash=sha256:e27f100e1ff17f6feeb1f33968bc185bf8ce41ca557deee9d9bbbffeb72030b7 \
--hash=sha256:f467a5fd23b4fc43ed86342641f3936a68ded707f4627622fa3f82a120e18256
yarl==1.9.3 ; python_version >= "3.10" and python_version < "4.0" \
--hash=sha256:09c19e5f4404574fcfb736efecf75844ffe8610606f3fccc35a1515b8b6712c4 \
--hash=sha256:0ab5baaea8450f4a3e241ef17e3d129b2143e38a685036b075976b9c415ea3eb \
Expand Down
10 changes: 8 additions & 2 deletions src/zconcurrent/zsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

import aiohttp
import msgspec
import uvloop

try:
import uvloop

asyncRun = uvloop.run
except ModuleNotFoundError:
asyncRun = asyncio.run


class RequestMap(msgspec.Struct):
Expand Down Expand Up @@ -32,7 +38,7 @@ def __init__(self, requestMaps: list[RequestMap]) -> None:
self._requestMaps: list[RequestMap] = requestMaps

def sendRequests(self, return_exceptions: bool = False) -> RequestResults:
return uvloop.run(self._sendRequests(rtn_exc=return_exceptions))
return asyncRun(self._sendRequests(rtn_exc=return_exceptions))

async def _sendRequests(self, rtn_exc: bool) -> RequestResults:
async with aiohttp.ClientSession() as session:
Expand Down

0 comments on commit b6355f6

Please sign in to comment.