Skip to content

add winloop support and remove deprecated functionality from uvloop#4996

Open
Vizonex wants to merge 8 commits intopsf:mainfrom
Vizonex:winloop
Open

add winloop support and remove deprecated functionality from uvloop#4996
Vizonex wants to merge 8 commits intopsf:mainfrom
Vizonex:winloop

Conversation

@Vizonex
Copy link

@Vizonex Vizonex commented Feb 19, 2026

Description

While I was going about writing a new tool for cython that would help me to format it's language and code neatly I was mainly trying to sift though this code in order to try and come up with some logical solutions or approaches for making a code / file writer since I'm implementing a new cython code formatting tool (and a few other cleaver tools in it's toolbag) since a formatting feature (as far as I am aware of) for cython does not exist. While attempting to read though this code to come up with some ideas, I saw that this library was using uvloop and having maintained a branch for windows I decided to add it in and remove some deprecated features that are in both libraries since I and the uvloop maintainers have already deprecated the install() function.

I might however need some guidance on what I should write in CHANGES.md but from there I should be ok to figure out what else I would need to do to get this pull request merged.

Checklist - did you ...

  • Implement any code style changes under the --preview style, following the stability policy?
  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this!

I like the function to return the loop. Cleaner.

As for CHANGES.md, just note it in the performance section I'd say and note it's also changed for blackd too.

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

diff-shades results comparing this PR (118e5c6) to main (4da809e):

--preview style: no changes

--stable style: no changes


What is this? | Workflow run | diff-shades documentation

@Vizonex Vizonex requested a review from cooperlees February 19, 2026 02:45
Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Thanks for this. I forgot about it. Well overdue.

Will leave it for a day or so to see if any other maintainer has preference otherwise I'll merge.

@cobaltt7
Copy link
Collaborator

cobaltt7 commented Feb 19, 2026

Thanks for this! It looks like CI found some crashes in blackd when running without uvloop, are you able to look into those?

Logs

[gw2] darwin -- Python 3.10.11 /Users/runner/work/black/black/.tox/ci-py310/bin/python
  + Exception Group Traceback (most recent call last):
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/runner.py", line 353, in from_call
  |     result: TResult | None = func()
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/runner.py", line 245, in 
  |     lambda: runtest_hook(item=item, **kwds),
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_hooks.py", line 512, in __call__
  |     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 167, in _multicall
  |     raise exception
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
  |     teardown.throw(exception)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/logging.py", line 850, in pytest_runtest_call
  |     yield
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
  |     teardown.throw(exception)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 53, in run_old_style_hookwrapper
  |     return result.get_result()
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_result.py", line 103, in get_result
  |     raise exc.with_traceback(tb)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 38, in run_old_style_hookwrapper
  |     res = yield
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
  |     teardown.throw(exception)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/capture.py", line 900, in pytest_runtest_call
  |     return (yield)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
  |     teardown.throw(exception)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/skipping.py", line 268, in pytest_runtest_call
  |     return (yield)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/pluggy/_callers.py", line 121, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 158, in pytest_runtest_call
  |     collect_unraisable(item.config)
  |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 81, in collect_unraisable
  |     raise ExceptionGroup("multiple unraisable exception warnings", errors)
  | exceptiongroup.ExceptionGroup: multiple unraisable exception warnings (3 sub-exceptions)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/Users/runner/work/black/black/tests/test_blackd.py", line 26, in tearDown
    |     gc.collect()
    | ResourceWarning: unclosed 
    | 
    | The above exception was the direct cause of the following exception:
    | 
    | Traceback (most recent call last):
    |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 67, in collect_unraisable
    |     warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
    | pytest.PytestUnraisableExceptionWarning: Exception ignored in: 
    | Enable tracemalloc to get traceback where the object was allocated.
    | See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/Users/runner/work/black/black/tests/test_blackd.py", line 26, in tearDown
    |     gc.collect()
    | ResourceWarning: unclosed 
    | 
    | The above exception was the direct cause of the following exception:
    | 
    | Traceback (most recent call last):
    |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 67, in collect_unraisable
    |     warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
    | pytest.PytestUnraisableExceptionWarning: Exception ignored in: 
    | Enable tracemalloc to get traceback where the object was allocated.
    | See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
    +---------------- 3 ----------------
    | Traceback (most recent call last):
    |   File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 688, in __del__
    |     _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
    | ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
    | 
    | The above exception was the direct cause of the following exception:
    | 
    | Traceback (most recent call last):
    |   File "/Users/runner/work/black/black/.tox/ci-py310/lib/python3.10/site-packages/_pytest/unraisableexception.py", line 67, in collect_unraisable
    |     warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
    | pytest.PytestUnraisableExceptionWarning: Exception ignored in: 
    | Enable tracemalloc to get traceback where the object was allocated.
    | See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
    +------------------------------------

Also, are you able to add windows-latest and windows-11-arm to the uvloop test runner too?

os: [ubuntu-latest, macOS-latest]

Thanks!

@Vizonex
Copy link
Author

Vizonex commented Mar 2, 2026

@cobaltt7 I'm going to see about making it so that there is a safer shutdown mechanism in place since some items are not closing correctly. I'll let you know if I run into false positives when running tests from my own windows 10 laptop.

@Vizonex
Copy link
Author

Vizonex commented Mar 2, 2026

@cobaltt7 Something strange and unusual that I've noticed is that when going through the test code if I disable gc.collect() by commenting it out in the teardown function on python 3.10 windows then test_blackd_main passes but test_blackd_python_variant fails. Doing it vice versa causes the opposite effect so I'm wondering if there could be a possible cleanup bug somewhere in the code or if it's an external dependency bug with aiohttp.

@Vizonex
Copy link
Author

Vizonex commented Mar 2, 2026

Came with with a workaround that closes the event loop after web.run_app so far all tests on my end seem to pass now. I wonder if I should bring this problem up with aiohttp later since I am a contributor to that library also.

@Vizonex Vizonex requested a review from cooperlees March 2, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants