Conversation
WITH CONFLICTS (resolved in subsequent commit):
both modified: aiohttp/__init__.py
both modified: docs/conf.py
Instead of TCPConnector taking a list of sockopts to be applied sockets
created, take a socket_factory callback that allows the caller to
implement socket creation entirely.
Fixes aio-libs#10520
CodSpeed Performance ReportMerging #10565 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 3.12 #10565 +/- ##
=======================================
Coverage 98.08% 98.08%
=======================================
Files 123 123
Lines 37450 37455 +5
Branches 2122 2120 -2
=======================================
+ Hits 36732 36737 +5
Misses 548 548
Partials 170 170
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1. Conflict resolution 2. Style fixes
9a35bc2 to
5d55c87
Compare
|
@bdraco @Dreamsorcerer let me know if you want me to squash the commits |
| `socket_factory` to the :class:`~aiohttp.TCPConnector`, which implements | ||
| `SocketFactoryType`. This will be used to create all sockets for the |
| Be sure to use ``aiohttp.AddrInfoType`` rather than | ||
| ``aiohappyeyeballs.AddrInfoType`` to avoid import breakage, as | ||
| it is likely to be removed from ``aiohappyeyeballs`` in the |
There was a problem hiding this comment.
Is it better to make these changes here, on the backport PR, or to commit some fixups to master to be backported? Or to commit them here then cherry-pick to master?
There was a problem hiding this comment.
Better yet, to make them in master, then add them to this PR
There was a problem hiding this comment.
It's a little cleaner to do the backport with no changes, merge it, then make the changes on master and the bot should be able to backport them from master to 3.12
There was a problem hiding this comment.
I'm sorry for the novice question, but how do I do that? I get
/Users/tmenninger/Downloads/aiohttp/docs/client_reference.rst:1136: WARNING: undefined label: 'aiohappyeyeballs' [ref.ref]
/Users/tmenninger/Downloads/aiohttp/docs/client_reference.rst:1150: WARNING: undefined label: 'aiohappyeyeballs' [ref.ref]
Am I supposed to define it somewhere?
There was a problem hiding this comment.
I'm sorry for the novice question, but how do I do that? I get
/Users/tmenninger/Downloads/aiohttp/docs/client_reference.rst:1136: WARNING: undefined label: 'aiohappyeyeballs' [ref.ref] /Users/tmenninger/Downloads/aiohttp/docs/client_reference.rst:1150: WARNING: undefined label: 'aiohappyeyeballs' [ref.ref]Am I supposed to define it somewhere?
If aiohappyeyeballs' docs have these objects, it'll work. You can verify which objects are exposed/exist via python -Im sphinx.ext.intersphinx. For non-existing objects, it's probably okay to ignore for now. However, you might find that there may be objects of different roles that you can link instead. Like :doc: instead of :ref: is okay sometimes.
| :param list tcp_sockopts: options applied to the socket when a connection is | ||
| created. This should be a list of 3-tuples, each a ``(level, optname, value)``. | ||
| Each tuple is deconstructed and passed verbatim to ``<socket>.setsockopt``. | ||
| :param :py:data:``SocketFactoryType`` socket_factory: This function takes an |
There was a problem hiding this comment.
The correct syntax is
| :param :py:data:``SocketFactoryType`` socket_factory: This function takes an | |
| :param SocketFactoryType socket_factory: This function takes an |
There was a problem hiding this comment.
I think I did this to get around
/Users/tmenninger/Downloads/aiohttp/docs/client_reference.rst:1015: WARNING: py:class reference target not found: SocketFactoryType [ref.class]
Is there a correct syntax to force it to consider SocketFactoryType a data rather than class?
There was a problem hiding this comment.
I don't think so. OTOH, everything in Python is an object and has a class. Param definitions expect classes / type annotations.
Also it's possible to move this into a separate :type: entry. I find that syntax cleaner.
SocketFactoryType looks like a constant and so I don't believe it to be a proper value anyway.
| created. This should be a list of 3-tuples, each a ``(level, optname, value)``. | ||
| Each tuple is deconstructed and passed verbatim to ``<socket>.setsockopt``. | ||
| :param :py:data:``SocketFactoryType`` socket_factory: This function takes an | ||
| :py:data:``AddrInfoType`` and is used in lieu of ``socket.socket()`` when |
There was a problem hiding this comment.
| :py:data:``AddrInfoType`` and is used in lieu of ``socket.socket()`` when | |
| :py:data:`AddrInfoType` and is used in lieu of :py:func:`socket.socket` when |
| want to change the conditions under which we consider a connection dead. | ||
| The following would change that to 9*7200 = 18 hours:: | ||
| If the default socket is insufficient for your use case, pass an optional | ||
| `socket_factory` to the :class:`~aiohttp.TCPConnector`, which implements |
There was a problem hiding this comment.
| `socket_factory` to the :class:`~aiohttp.TCPConnector`, which implements | |
| ``socket_factory`` to the :class:`~aiohttp.TCPConnector`, which implements |
There was a problem hiding this comment.
Perhaps symlink this change note to the new one. Both are a part of this, right?
|
I took care of the backport in #10574 so once we have the docs PR for master ready, it should cherry-pick cleanly to 3.12 |
What do these changes do?
Replace
tcp_sockoptsparameter with asocket_factoryparameter thatis a callback allowing the caller to own socket creation. If passed, all
sockets created by
TCPConnectorare expected to come from thesocket_factorycallback.Are there changes in behavior for the user?
The only users to experience a change in behavior are those who are
using the un-released
tcp_sockoptsargument toTCPConnector.However, using unreleased code comes with caveat emptor, and is why I
felt entitled to remove the option entirely without warning.
Is it a substantial burden for the maintainers to support this?
The burden will be minimal and would only arise if
aiohappyeyeballschanges their interface.
Related issue number
Fixes #10520
Checklist
CONTRIBUTORS.txtCHANGES/foldername it
<issue_or_pr_num>.<type>.rst(e.g.588.bugfix.rst)if you don't have an issue number, change it to the pull request
number after creating the PR
.bugfix: A bug fix for something the maintainers deemed animproper undesired behavior that got corrected to match
pre-agreed expectations.
.feature: A new behavior, public APIs. That sort of stuff..deprecation: A declaration of future API removals and breakingchanges in behavior.
.breaking: When something public is removed in a breaking way.Could be deprecated in an earlier release.
.doc: Notable updates to the documentation structure or buildprocess.
.packaging: Notes for downstreams about unobvious side effectsand tooling. Changes in the test invocation considerations and
runtime assumptions.
.contrib: Stuff that affects the contributor experience. e.g.Running tests, building the docs, setting up the development
environment.
.misc: Changes that are hard to assign to any of the abovecategories.
Make sure to use full sentences with correct case and punctuation,
for example:
Use the past tense or the present tense a non-imperative mood,
referring to what's changed compared to the last released version
of this project.
Co-authored-by: J. Nick Koston nick@koston.org