sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.

Home Page:https://sanic.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Python 3.12

robd003 opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

Currently unable to use Sanic with Python 3.12

Describe the solution you'd like

uvloop 0.18.0 was just released and supports Python 3.12

It'd be great to get support for Python 3.12 on the next release of Sanic along with the 2022.12 LTS release

Additional context

No response

Making this the tracking issue for Python 3.12 compatibility. Please post any incompatibilities found here. We probably need to update some dependencies, and add 3.12 testing to our CI. Rarely have any Python updates (other than asyncio loop argument removal) prompted for changes in Sanic itself.

@ahopkins Is this feature something what is okay to pick up into progress by someone whom isn't part of the core maintainers group ?

@iAndriy Feel free to hack it, PRs from anyone are welcome here! And core developers are quite overloaded already =)

A good start would be to just add to the CI, open a PR, mark it as draft and list out all the errors you encountered.

First and foremost add it to tox.ini and run the tests.

tox -e py312

A good start would be to just add to the CI, open a PR, mark it as draft and list out all the errors you encountered.

First and foremost add it to tox.ini and run the tests.

tox -e py312

@ahopkins thanks for suggestion

Some of upstreams libraries used by sanic doesn't support Python 3.12:

The failure of test suite for py312 in #2870 is related to errors caused from by CIMultiDict

@ahopkins @Tronic Looks like we need to wait a bit, so upstream libraries would catch up with latest python.
Related MR: #2870, see test execution for python 3.12 + comment above for more details.
How do you usually overcome such use cases ?

This is usually what prevents the upgrade for us.Usually it's uvloop we have to wait for.

We can ping @aaugustin to ask when he plans to add 3.12 to websockets.

websockets works on Python 3.12 without any code changes. There's even Python 3.12 wheels for websockets 12.0 on PyPI.

Only the Python 3.12 trove classifier is missing on PyPI. I will add it; however, I believe this metadata is indicative and doesn't affect whether pip & friends will accept to install a library. This shouldn't prevent you from moving forwards.

If I'm missing something here and the missing classifier is actually a blocker, then I can do a quick 12.0.1 release just to fix that!

Thanks @aaugustin! @iAndriy can you take a look? I don't think the lack of classifier would hold us back.

@aaugustin Thanks for getting back and closing this metadata thing.

@ahopkins
Yeah, let me circle back on this one.

@ahopkins I've updated MR, issues seems to be in the CIMultiDict call flow. For python3.12 the following call results in Segmentation Fault ( see screenshot), nonetheless it works if no kwargs used.
Screenshot 2023-12-17 at 17 12 45

Experiencing the same issue as @iAndriy Through websocket endpoints though.

Relevant issue within multidict: aio-libs/multidict#898

  • no error present when kwargs aren't used.

@JoeriHermans It seems to work without kwargs passing.