Commit 40521c8
authored
Re-use connections when remote S3 signing (#2543)
# Rationale for this change
The existing S3 remote signing hook function (`s3v4_rest_signer`) uses
`requests.post` to submit `POST` requests to the REST signing endpoint.
This internally creates a new `requests.Session` for every request,
preventing any reuse of connections.
In my profiling I saw this add overhead from repeated loading of CA
certs and reestablishing of TLS connections.
This change makes the signing function a callable object that wraps a
`request.Session`, using this for `POST`ing, therefore achieving
connection reuse.
Signer callables are stored on the hook internals of the `aiobotocore`
client inside the `s3fs.S3FileSystem` instance, so use and lifetime will
match that of those instances. They are thread-local since:
#2495.
## Are these changes tested?
Tested locally. Existing unit tests updated for changes.
## Are there any user-facing changes?
Yes - S3 signing requests now use connection pools (scoped to the
`s3fs.S3FileSystem` object).1 parent 8c545d9 commit 40521c8
2 files changed
+62
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 101 | + | |
| 102 | + | |
102 | 103 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 104 | + | |
107 | 105 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
114 | 118 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
121 | 122 | | |
122 | | - | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
124 | 145 | | |
125 | | - | |
| 146 | + | |
| 147 | + | |
126 | 148 | | |
127 | | - | |
| 149 | + | |
128 | 150 | | |
129 | 151 | | |
130 | | - | |
| 152 | + | |
131 | 153 | | |
132 | 154 | | |
133 | 155 | | |
| |||
145 | 167 | | |
146 | 168 | | |
147 | 169 | | |
148 | | - | |
| 170 | + | |
149 | 171 | | |
150 | 172 | | |
151 | 173 | | |
152 | | - | |
153 | | - | |
154 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
155 | 177 | | |
156 | 178 | | |
157 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
844 | 844 | | |
845 | 845 | | |
846 | 846 | | |
847 | | - | |
| 847 | + | |
| 848 | + | |
848 | 849 | | |
849 | | - | |
850 | | - | |
| 850 | + | |
| 851 | + | |
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
| |||
898 | 899 | | |
899 | 900 | | |
900 | 901 | | |
901 | | - | |
| 902 | + | |
| 903 | + | |
902 | 904 | | |
903 | | - | |
904 | | - | |
| 905 | + | |
| 906 | + | |
905 | 907 | | |
906 | 908 | | |
907 | 909 | | |
| |||
939 | 941 | | |
940 | 942 | | |
941 | 943 | | |
| 944 | + | |
942 | 945 | | |
943 | | - | |
| 946 | + | |
944 | 947 | | |
945 | 948 | | |
946 | 949 | | |
| |||
0 commit comments