Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions .circleci/config.yml

This file was deleted.

5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ jobs:
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
requirements.txt
setup.cfg
pyproject.toml
- name: Install dependencies
run: |
pip install -q -U pip
pip install --progress-bar=off -r requirements.txt
pip install --progress-bar=off .
pip install --progress-bar=off '.[testing]'
- name: Lint
run: |
make lint
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
lint:
flake8 aiosocketpool/
flake8 --max-line-length=100 --ignore=E203,W503 aiosocketpool/
black -l 100 --check aiosocketpool/ tests/
pydocstyle --convention=numpy --add-ignore=D100,D101,D102,D103,D104,D105,D202 aiosocketpool/ tests/
mypy .
mypy aiosocketpool/ tests/
format:
black -l 100 aiosocketpool/ tests/
test:
Expand Down
14 changes: 0 additions & 14 deletions Pipfile

This file was deleted.

237 changes: 0 additions & 237 deletions Pipfile.lock

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Circle CI](https://circleci.com/gh/polyatail/aiosocketpool.svg?style=shield&circle-token=f7f570b230ecf72d3df817cca445c5a28809068a)](https://circleci.com/gh/onecodex/mainline)
![Black Code Style](https://camo.githubusercontent.com/28a51fe3a2c05048d8ca8ecd039d6b1619037326/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d626c61636b2d3030303030302e737667)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![CI](https://github.com/polyatail/aiosocketpool/actions/workflows/ci.yml/badge.svg)](https://github.com/polyatail/aiosocketpool/actions/workflows/ci.yml)

# aiosocketpool
An asyncio-compatible socket pool. Simple, compact, easily extended.
Expand All @@ -10,7 +10,7 @@ every request. Combining an `asyncio` event loop and a socket pool might be the

Based on [socketpool](https://github.com/benoitc/socketpool).

**Requires Python 3.7 or above.**
**Requires Python 3.8 or above.**

## Examples

Expand Down Expand Up @@ -81,4 +81,4 @@ for _ in range(25):
tasks.append(loop.create_task(hello_world()))

loop.run_until_complete(asyncio.gather(*tasks))
```
```
15 changes: 8 additions & 7 deletions aiosocketpool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import select
import socket
import time
from typing import Optional, Type, AsyncGenerator
from typing import Optional, Type, AsyncGenerator, Any, cast
import weakref


Expand Down Expand Up @@ -60,23 +60,24 @@ def is_connected(sock: socket.socket):
return True
p.unregister(fno)
elif can_use_kqueue():
kq = select.kqueue()
sel = cast(Any, select)
kq = sel.kqueue()
events = [
select.kevent(fno, select.KQ_FILTER_READ, select.KQ_EV_ADD),
select.kevent(fno, select.KQ_FILTER_WRITE, select.KQ_EV_ADD),
sel.kevent(fno, sel.KQ_FILTER_READ, sel.KQ_EV_ADD),
sel.kevent(fno, sel.KQ_FILTER_WRITE, sel.KQ_EV_ADD),
]
kq.control(events, 0)
kevents = kq.control(None, 4, 0)
for ev in kevents:
if ev.ident == fno:
if ev.flags & select.KQ_EV_ERROR:
if ev.flags & sel.KQ_EV_ERROR:
return False
else:
return True

events = [
select.kevent(fno, select.KQ_FILTER_READ, select.KQ_EV_DELETE),
select.kevent(fno, select.KQ_FILTER_WRITE, select.KQ_EV_DELETE),
sel.kevent(fno, sel.KQ_FILTER_READ, sel.KQ_EV_DELETE),
sel.kevent(fno, sel.KQ_FILTER_WRITE, sel.KQ_EV_DELETE),
]
kq.control(events, 0)
kq.close()
Expand Down
Loading