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

Acurl use Cython 3.0.8 #280

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-2019 Sky UK. https://www.sky.com/
Copyright (c) 2016-2024 Sky UK. https://www.sky.com/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion acurl/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "Cython<3.0"]
requires = ["setuptools", "wheel", "Cython>=3.0.8,<4.0.0"]
10 changes: 5 additions & 5 deletions acurl/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ classifiers =
Intended Audience :: Developers
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
author = Aaron Ecay
author_email = [email protected]
maintainer = Sky Identity NFT team
maintainer_email = matthew.ellis@sky.uk
maintainer = Sky Digital Identity NFT team
maintainer_email = jordan.brennan@sky.uk
license = MIT
url = https://github.com/sky-uk/mite/tree/master/acurl
version = 1.0.7
version = 1.0.8

[options]
install_requires =
ujson>=4.1.0
uvloop
uvloop==0.21.0b1
tests_require = pytest

[aliases]
Expand Down
6 changes: 4 additions & 2 deletions acurl/src/acurl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AcurlError(Exception):
# with the python asyncio library we need to call back into python. So these
# functions do take the GIL, as indicated by `with gil` in their signatures.
# The performance impact of this is yet tbd.
cdef int handle_socket(CURL *easy, curl_socket_t sock, int action, void *userp, void *socketp) with gil:
cdef int handle_socket(CURL *easy, curl_socket_t sock, int action, void *userp, void *socketp) noexcept with gil:
ryanlinnit-sky marked this conversation as resolved.
Show resolved Hide resolved
cdef CurlWrapper wrapper = <CurlWrapper>userp
if action == CURL_POLL_IN or action == CURL_POLL_INOUT:
wrapper.loop.add_reader(sock, wrapper.curl_perform_read, wrapper, sock)
Expand All @@ -30,10 +30,12 @@ cdef int handle_socket(CURL *easy, curl_socket_t sock, int action, void *userp,
if action == CURL_POLL_REMOVE:
wrapper.loop.remove_reader(sock)
wrapper.loop.remove_writer(sock)
# The following exception is never expected to be hit. Further conversation
# regarding this can be found in the PR: https://github.com/sky-uk/mite/pull/280#discussion_r1723665976
if action != CURL_POLL_IN and action != CURL_POLL_OUT and action != CURL_POLL_INOUT and action != CURL_POLL_REMOVE:
raise Exception("oops")

cdef int start_timeout(CURLM *multi, long timeout_ms, void *userp) with gil:
cdef int start_timeout(CURLM *multi, long timeout_ms, void *userp) noexcept with gil:
cdef CurlWrapper wrapper = <CurlWrapper>userp
cdef int _running
cdef double secs
Expand Down
4 changes: 2 additions & 2 deletions acurl/src/session.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cdef BufferNode* alloc_buffer_node(size_t size, char *data):
node.next = NULL
return node

cdef size_t header_callback(char *ptr, size_t size, size_t nmemb, void *userdata):
cdef size_t header_callback(char *ptr, size_t size, size_t nmemb, void *userdata) noexcept:
Copy link
Collaborator

Choose a reason for hiding this comment

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

OTOH, this function (and the one below it in this file) really can't raise, and so are valid noexcept candidates with no explanation needed.

cdef _Response response = <_Response>userdata
cdef BufferNode* node = alloc_buffer_node(size * nmemb, ptr)
if response.header_buffer == NULL: # FIXME: unlikely
Expand All @@ -42,7 +42,7 @@ cdef size_t header_callback(char *ptr, size_t size, size_t nmemb, void *userdata
response.header_buffer_tail = node
return node.len

cdef size_t body_callback(char *ptr, size_t size, size_t nmemb, void *userdata):
cdef size_t body_callback(char *ptr, size_t size, size_t nmemb, void *userdata) noexcept:
cdef _Response response = <_Response>userdata
cdef BufferNode* node = alloc_buffer_node(size * nmemb, ptr)
if response.body_buffer == NULL: # FIXME: unlikely
Expand Down
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ description = A Python Performance Testing Framework
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/sky-uk/mite/
python_requires = >=3.9
python_requires = >=3.10
classifiers =
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Operating System :: POSIX :: Linux

# TODO - Update (or remove) the Selenium version when migrating to v4. The version is explicitly defined
Expand All @@ -26,7 +26,8 @@ install_requires =
nanomsg
pyzmq
selenium<4
uvloop
setuptools
ryanlinnit-sky marked this conversation as resolved.
Show resolved Hide resolved
uvloop==0.21.0b1
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, do we know why we are pinning to a specific version, especially a beta one? what are the conditions in the future under which we could remove the pin?

websockets
setup_requires = pytest-runner
packages = find:
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ pytest-httpbin
pytest-httpserver
sanic
werkzeug==3.0.3
uvloop==0.19.0
uvloop==0.21.0b1
Copy link
Collaborator

Choose a reason for hiding this comment

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

eek -- the test should not be pinned to a different version than the main code, so it's good to change this (tho no pinning would be ideal).

it's been a while since i looked at this code, but IIRC, the tests install everything from setup.cfg as well as everything from the test-requirements.txt. so given that uvloop is already required by setup.cfg, we could delete it from here and avoid any future iterations of the different-pinning problem. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting errors due to it not the version of uvloop required for Cython 3. (This commit). Which is why I pinned it to version 0.21.0b1. I'll put this PR back in drafts whilst I fix them etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ahhh, uvloop doesn't have a stable release for cython3 yet. that explains it. do we want to wait for upstream to cut a stable release? that should avoid us needing to do any pinning. if we don't want to wait, we can just stick a comment in explaining the situation, and Someone™ can remove the comment and the pin in the future....