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
19 changes: 8 additions & 11 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<!--
<!--
IMPORTANT NOTICE

- 1. YOU ARE NOT A KINDERGARTENER, AI GENERATED ISSUES WILL BE DISCARDED. DO NOT ATTEMPT TO MAKE THESE.
TAKE YOUR SWEET AND PRECIOUS TIME FOR US AND WE WILL BE ABLE TO COMMUNICATE WITH YOU BETTER

- 2. PLEASE HAVE COMMON SENSE. INNAPROPERATE ISSUES ARE ALWAYS DISCARDED.
- 2. PLEASE HAVE COMMON SENSE. INNAPROPERATE ISSUES ARE ALWAYS DISCARDED.

- 3. KEEP YOUR PROFANITY CONTAINED IF POSSIBLE.
- 3. KEEP YOUR PROFANITY CONTAINED IF POSSIBLE.
-->

## ISSUE
<!-- Please give a short and sweet summary about the issue your experiencing please know that
if your not on windows please send the issue to uvloop instead -->

<!-- Fill this out too it's important for all of us to know what you want or what your goal is -->
<!-- Fill this out too it's important for all of us to know what you want or what your goal is -->
- [ ] bug
- [ ] optimization idea

## TO REPRODUCE
<!--
If this problem is not an optimization idea, please
create a short and sweet python script with the problem you are facing
<!--
If this problem is not an optimization idea, please
create a short and sweet python script with the problem you are facing
An Example of this done right is https://github.com/Vizonex/Winloop/issues/84
The script you create will be used to ensure winloop runs correctly.

```python
```python
import winloop

async def main():
Expand All @@ -36,6 +36,3 @@ if __name__ == "__main__":
```

-->



6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Template comes from aiolibs that I will so happily borrow for our own use-cases - Vizonex
<!--
Template comes from aiolibs that I will so happily borrow for our own use-cases - Vizonex
-->
<!-- Thank you for your contribution! -->

Expand Down Expand Up @@ -31,7 +31,7 @@ entertain early in the review process. Thank you in advance!
<!-- Remember to prefix with 'Fixes' if it closes an issue (e.g. 'Fixes #123'). -->

## Checklist
<!-- These Are important the more you check off and actually perform the
<!-- These Are important the more you check off and actually perform the
higher the chance your pull request succeeds. -->

- [ ] I think the code is well written
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Borrowed from pycares & cyares,
# this will be the nightly build I've
# been talking about adding for the past 2 years,
# Borrowed from pycares & cyares,
# this will be the nightly build I've
# been talking about adding for the past 2 years,
# - Vizonex

name: Build Wheels
Expand Down Expand Up @@ -28,4 +28,4 @@ jobs:
with:
path: dist
merge-multiple: true
- run: ls -lR dist
- run: ls -lR dist
19 changes: 19 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Pre-commit

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: pre-commit/action@v3.0.1
2 changes: 1 addition & 1 deletion .github/workflows/release-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types:
- published

permissions:
permissions:
contents: write

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# Nb. keep cibuildwheel version pin consistent with job below
run: pipx install cibuildwheel==3.2.1
- id: set-matrix
# Trimmed out setupmatrix for just windows but I might look at compiling other oses just for fun
# Trimmed out setupmatrix for just windows but I might look at compiling other oses just for fun
# to let others test what it would be like if uvloop supported windows. It's very tempting...
run: |
MATRIX=$(
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run-sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ jobs:
- name: Install setuptools
run: python -m pip install -U setuptools
- name: Install Cython
run : python -m pip install cython
run : python -m pip install cython
- name: Build sdist
run: python setup.py sdist
- uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz

8 changes: 2 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install Requirements
run: python -m pip install --upgrade setuptools wheel pip cython pytest aiohttp aiodns

- name: Compile Winloop
run: pip install -e .

- name: run-tests
env:
COLOR: yes
PIP_USER: 1
run: pytest -vv
shell: bash




29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://pre-commit.com for usage and config reference.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
exclude: |
(?x)^(
vendor/.*|
.*\.pyc|
.*\.pyd|
.*\.so|
.*\.pyx\.c
)$
args:
- --ignore-words-list=asince,bu,hist,nd,noe,ot,te,ue,wan,wile,ans,crate,cas,trough,conection,exection,fo,ist,nam,no,onot,pres,ser,set,start,uint,axcept,alloc,ba,cycl,fulllist,indx,isin,inout,les,ls,mut,nin,releated,sice,splited,unser,vas,wether,assertin,asend

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.16.0
hooks:
- id: cython-lint
args:
- --no-pycodestyle
2 changes: 1 addition & 1 deletion LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ Copyright (C) 2023-present Vizonex, the winloop authors and winloop contributors
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,16 @@ if __name__ == "__main__":


## TODO-List
- [ ] In Winloop 0.2.0 or before 2026 I would like to start planning to migrate to pytest so that things could be formatted a little better.
A Migration Python script might be needed or looked into.
- [ ] In Winloop 0.2.0 or before 2026 I would like to start planning to migrate to pytest so that things could be formatted a little better.
A Migration Python script might be needed or looked into.

- [ ] Update Fastapi Example to a more recent version of fastapi

- [ ] Help Wanted. We're looking for other maintainers to help us.

- [x] Nightly Builds And Test Suite Workflows for anyone wanting to use newer unreleased versions. (Done, it runs now)

- [ ] Adding in the necessary hooks for pyinstaller to compile this fast library to executable code even though hooks have been known to inflate the size of the `.exe` files. This is because calling hidden-imports for all the `__init__.py` modules might annoy some developers. (Luckily I'm aware of this issue because I've been doing this myself...) [Update, This is now pending and I hope that it passes](https://github.com/pyinstaller/pyinstaller-hooks-contrib/pull/867)
- [ ] Adding in the necessary hooks for pyinstaller to compile this fast library to executable code even though hooks have been known to inflate the size of the `.exe` files. This is because calling hidden-imports for all the `__init__.py` modules might annoy some developers. (Luckily I'm aware of this issue because I've been doing this myself...) [Update, This is now pending and I hope that it passes](https://github.com/pyinstaller/pyinstaller-hooks-contrib/pull/867)

- [x] write a workflow for nightly builds if necessary for verification of pull requests.

Expand Down
2 changes: 1 addition & 1 deletion tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ async def main(n):
for i in range(n):
try:
await asyncio.create_subprocess_exec(
"nonexistant",
"nonexistent",
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ def server(sock):
pass
self.assertEqual(data, B_DATA)
if conn.renegotiate_pending():
conn.send(b"ERRO")
conn.send(b"ER")
else:
conn.send(b"SPAM")

Expand Down
13 changes: 6 additions & 7 deletions winloop/errors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cdef __convert_python_error(int uverr):
# Implementation detail: on Unix error codes are the
# negated errno (or -errno), while on Windows they
# are defined by libuv to arbitrary negative numbers.

cdef int oserr
cdef object err

Expand All @@ -20,10 +20,10 @@ cdef __convert_python_error(int uverr):
# Winloop has a smarter technique for showing these errors.
err = getattr(win_errno, uv.uv_err_name(uverr).decode(), uverr)
return OSError(err, uv.uv_strerror(uverr).decode())

oserr = -uverr


exc = OSError

if uverr in (uv.UV_EACCES, uv.UV_EPERM):
Expand Down Expand Up @@ -121,9 +121,9 @@ cdef convert_error(int uverr):

sock_err = __convert_socket_error(uverr)
if sock_err:
# Winloop comment: Sometimes libraries will throw in some
# Winloop comment: Sometimes libraries will throw in some
# unwanted unicode BS to unravel, to prevent the possibility of this being a threat,
# surrogateescape is utilized
# surrogateescape is utilized
# SEE: https://github.com/Vizonex/Winloop/issues/32
msg = system.gai_strerror(sock_err).decode('utf-8', "surrogateescape")
# Winloop comment: on Windows, cPython has a simpler error
Expand All @@ -134,7 +134,6 @@ cdef convert_error(int uverr):
if sys_platform == "win32":
if sock_err in (socket_EAI_FAMILY, socket_EAI_NONAME):
msg = 'getaddrinfo failed'
return socket_gaierror(sock_err, msg)
return socket_gaierror(sock_err, msg)

return __convert_python_error(uverr)

24 changes: 12 additions & 12 deletions winloop/handles/process.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cdef class UVProcess(UVHandle):
self._restore_signals = restore_signals

loop.active_process_handler = self


if not system.PLATFORM_IS_WINDOWS:
__forking = 1
Expand All @@ -101,12 +101,12 @@ cdef class UVProcess(UVHandle):
PyOS_BeforeFork()
else:
py_gil_state = PyGILState_Ensure()

err = uv.uv_spawn(loop.uvloop,
<uv.uv_process_t*>self._handle,
&self.options)


if not system.PLATFORM_IS_WINDOWS:
__forking = 0
__forking_loop = None
Expand All @@ -115,7 +115,7 @@ cdef class UVProcess(UVHandle):
PyOS_AfterFork_Parent()
else:
PyGILState_Release(py_gil_state)

loop.active_process_handler = None


Expand Down Expand Up @@ -439,7 +439,7 @@ cdef class UVProcessTransport(UVProcess):
else:
self._pending_calls.append((_CALL_PIPE_DATA_RECEIVED, fd, data))



cdef _file_redirect_stdio(self, int fd):
fd = os_dup(fd)
Expand Down Expand Up @@ -494,13 +494,13 @@ cdef class UVProcessTransport(UVProcess):
'subprocess.STDOUT is supported only by stderr parameter')
else:
io[0] = self._file_redirect_stdio(_stdin)

elif system.PLATFORM_IS_WINDOWS and system.__UVLOOP_STDIN_BAD:

# When a stdio is in a gui-like state without a console.
# using a standard redirect is not a good idea. This at least
# is a better workaround that is a bit cleaner than doing what the
# python standard library subprocess does with the _get_handles function
# is a better workaround that is a bit cleaner than doing what the
# python standard library subprocess does with the _get_handles function
# on windows. SEE: https://github.com/Vizonex/Winloop/issues/126

io[0] = self._file_devnull()
Expand Down Expand Up @@ -559,7 +559,7 @@ cdef class UVProcessTransport(UVProcess):
io[2] = self._file_devnull()
else:
io[2] = self._file_redirect_stdio(_stderr)

elif system.PLATFORM_IS_WINDOWS and system.__UVLOOP_STDOUT_BAD:
io[2] = self._file_devnull()
else:
Expand Down Expand Up @@ -817,7 +817,7 @@ cdef __socketpair():
int err

# Winloop comment: no Unix sockets on Windows, using uv.uv_pipe()
# instead of system.socketpair(). Also, see changes to
# instead of system.socketpair(). Also, see changes to
# libuv/src/win/pipe.c to deal with UV_EPERM = -4048 errors
# for stdin pipe.
if system.PLATFORM_IS_WINDOWS:
Expand Down
11 changes: 5 additions & 6 deletions winloop/handles/stream.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ cdef class _StreamWriteContext:
_StreamWriteContext ctx
int uv_bufs_idx = 0
size_t py_bufs_len = 0
int i

Py_buffer* p_pybufs
uv.uv_buf_t* p_uvbufs
Expand Down Expand Up @@ -355,7 +354,7 @@ cdef class UVStream(UVBaseTransport):
Py_ssize_t blen
int saved_errno
int fd

if system.PLATFORM_IS_WINDOWS:
# Winloop comment: WSASend below does not work with pipes.
# For pipes, using Writefile() from Windows fileapi.h would
Expand Down Expand Up @@ -445,7 +444,7 @@ cdef class UVStream(UVBaseTransport):
cdef bint all_sent

if (not self._protocol_paused and
(<uv.uv_stream_t*>self._handle).write_queue_size == 0 and
(<uv.uv_stream_t*>self._handle).write_queue_size == 0 and
self._buffer_size > self._high_water):
# Fast-path. If:
# - the protocol isn't yet paused,
Expand Down Expand Up @@ -693,12 +692,12 @@ cdef class UVStream(UVBaseTransport):

cpdef write(self, object buf):
self._ensure_alive()

if system.PLATFORM_IS_WINDOWS:
# Winloop Comment: Winloop gets itself into trouble if this is
# is not checked immediately, it's too costly to call the python function
# is not checked immediately, it's too costly to call the python function
# bring in the flag instead to indicate closure.
# SEE: https://github.com/Vizonex/Winloop/issues/84
# SEE: https://github.com/Vizonex/Winloop/issues/84
if self._closing:
raise RuntimeError("Cannot call write() when UVStream is closing")

Expand Down
Loading
Loading