Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize and fix CI #121

Merged
merged 9 commits into from
Aug 5, 2023
Merged

Modernize and fix CI #121

merged 9 commits into from
Aug 5, 2023

Conversation

oremanj
Copy link
Member

@oremanj oremanj commented Jul 12, 2023

Code changes:

  • Port from MultiError to ExceptionGroup, thus supporting (and requiring) Trio v0.22.0+.
  • Drop support for 3.6 (required by ExceptionGroup support).
  • Required by a new test in 3.12 but a good idea anyway: Route exceptions from asyncio callbacks through the default exception handler.
  • Required by exception change above: Stop using StopAsyncIteration to indicate that the trio-asyncio loop should exit. Instead use a new TrioAsyncioExit exception, which derives from SystemExit and thus will pass through asyncio internals.
  • Required by exception change above: Actually raise uncaught exceptions out of open_loop() when using an async loop, instead of just claiming to. Raising them out of default_exception_handler doesn't work because asyncio catches it. Instead we now create a new task in the loop nursery to raise the exception.
  • Noticed because of exception change above: Fix a race condition where add_reader or add_writer on a socket object (rather than fd) could produce an uncaught exception if the reader/writer were unregistered and the socket closed inside the same reader/writer callback.
  • Monkeypatch asyncio.current_task on 3.12+ so that it looks at the current_loop contextvar instead of just the C-level running loop cache. This is now necessary because current_task is now implemented in C and thus bypasses our monkeypatches by default.
  • Clear Trio state on fork (required by new tests in 3.12).

Test changes:

  • Test on 3.10, 3.11, 3.12-dev, and recent pypy.
  • Move setup.cfg and pytest.ini into pyproject.toml.
  • Update the pytest plugin that runs stdlib asyncio tests so it doesn't use deprecated pytest features.

Closes #119, #120.

oremanj added 2 commits July 12, 2023 17:13
Test on 3.10, 3.11, 3.12-dev, and recent pypy. Port from MultiError to ExceptionGroup, thus supporting (and requiring) Trio v0.22.0+. Drop support for 3.6 (required by ExceptionGroup support).
@oremanj oremanj force-pushed the fix-tests branch 2 times, most recently from 857e23e to 80d6ff1 Compare July 13, 2023 08:56
Trio-Asyncio requires at least Python 3.6. It is tested on recent versions of
3.6, 3.7, 3.8, and nightly.
Trio-Asyncio requires at least Python 3.7. It is tested on recent versions of
3.7 through 3.11, plus 3.12-dev.

Choose a reason for hiding this comment

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

3.12 isn't tested on CI though? Maybe that should be added to the config?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's tested on Ubuntu. The test matrix is basically copied from current Trio; I don't know how to do prereleases on other platforms on GHA, and I don't think they'd add much additional coverage. We can add them once 3.12 final is out.

ci.sh Outdated
@@ -72,14 +38,6 @@ python -m pip --version
python setup.py sdist --formats=zip

Choose a reason for hiding this comment

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

Maybe use a PEP 517 build process (python -m build -s), as invoking python setup.py is deprecated?
Alternatively, pip install . would probably be simpler while still being modern.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to pip install .

setup.py Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@dhirschfeld
Copy link
Member

bump!

Is there anything preventing this being merged?

@oremanj
Copy link
Member Author

oremanj commented Jul 28, 2023

Is there anything preventing this being merged?

Just the fact that no one has approved it.

@dhirschfeld
Copy link
Member

Since @agronholm has reviewed I'll let him approve if he's not too busy...

@agronholm
Copy link

I may be a little out of my depth here but I'll see if I can give this a proper review over the weekend.

Copy link

@agronholm agronholm left a comment

Choose a reason for hiding this comment

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

I didn't find anything wrong; just a note about Python version classifiers.

@@ -91,7 +87,6 @@
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",

Choose a reason for hiding this comment

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

Maybe add more Python version classifiers?

Copy link
Member

@CoolCat467 CoolCat467 left a comment

Choose a reason for hiding this comment

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

This looks good, but I would feel more comfortable if someone more familiar with the internals of asyncio had a look at this as well.

@oremanj oremanj merged commit a3ffea7 into python-trio:master Aug 5, 2023
@oremanj oremanj deleted the fix-tests branch November 6, 2023 22:35
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.

MultiError deprecation warnings from trio
4 participants