This repository was archived by the owner on Apr 14, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork9
Commit339024b
committed
Better Python 2 / 3 compatibility
This fixes the breaking changes for Python 2 that were made in thelast attempt and improves Python 3 compatibility a bit more.Python 3 supports the new `file` argument to the `print` functionthat allows you to specify where to print to. In the code, thiswas being used to print to stderr. Unfortunately Python 2 does notyet support this, so we are now using `sys.stderr.write` instead.Python 2's `Queue` module was renamed to `queue` in Python 3. Weshould be importing them both to ensure that the code runs on bothversions. By default, we are assuming that Python 3 will be usedand are using it as the first import before falling back to the oldname.`threading._sleep` was a private method and was removed in Python 3.It has been replaced by `time.sleep` for now, as that is both publicand consistent across versions.When determining chunk sizes and the number of chunks, there was apossibility of floating values being passed in or calculated. Toensure that the generated range does not throw an exception, we aremanually casting these to integers.The iterator was previously changed so `next` became `__next__`,which was the Python 3 method for the `next` function. This addsPython 2 compatibility alongside of these changes.1 parent9a25914 commit339024b
File tree
9 files changed
+82
-52
lines changed- async
- test
9 files changed
+82
-52
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
33 |
| - | |
| 33 | + | |
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
|
Lines changed: 14 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 |
| - | |
8 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 |
| |
10 | 16 |
| |
11 | 17 |
| |
| |||
161 | 167 |
| |
162 | 168 |
| |
163 | 169 |
| |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
164 | 174 |
| |
165 | 175 |
| |
166 | 176 |
| |
| |||
332 | 342 |
| |
333 | 343 |
| |
334 | 344 |
| |
335 |
| - | |
| 345 | + | |
336 | 346 |
| |
337 | 347 |
| |
338 | 348 |
| |
|
Lines changed: 13 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
18 |
| - | |
19 |
| - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
20 | 26 |
| |
21 | 27 |
| |
22 | 28 |
| |
| |||
277 | 283 |
| |
278 | 284 |
| |
279 | 285 |
| |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
280 | 290 |
| |
281 | 291 |
| |
282 | 292 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 |
| |
9 | 12 |
| |
10 | 13 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
38 | 38 |
| |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
| 41 | + | |
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
| |||
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
52 |
| - | |
| 52 | + | |
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
|
Lines changed: 31 additions & 32 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
| 26 | + | |
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| |||
71 | 71 |
| |
72 | 72 |
| |
73 | 73 |
| |
74 |
| - | |
75 |
| - | |
76 |
| - | |
77 |
| - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
| |||
162 | 162 |
| |
163 | 163 |
| |
164 | 164 |
| |
165 |
| - | |
166 |
| - | |
| 165 | + | |
| 166 | + | |
167 | 167 |
| |
168 | 168 |
| |
169 | 169 |
| |
| |||
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
210 |
| - | |
211 |
| - | |
212 |
| - | |
213 |
| - | |
214 |
| - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
215 | 215 |
| |
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
219 |
| - | |
220 |
| - | |
| 219 | + | |
| 220 | + | |
221 | 221 |
| |
222 | 222 |
| |
223 | 223 |
| |
| |||
243 | 243 |
| |
244 | 244 |
| |
245 | 245 |
| |
246 |
| - | |
247 |
| - | |
248 |
| - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
249 | 249 |
| |
250 | 250 |
| |
251 | 251 |
| |
| |||
257 | 257 |
| |
258 | 258 |
| |
259 | 259 |
| |
260 |
| - | |
261 |
| - | |
262 |
| - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
263 | 263 |
| |
264 | 264 |
| |
265 | 265 |
| |
| |||
277 | 277 |
| |
278 | 278 |
| |
279 | 279 |
| |
280 |
| - | |
281 |
| - | |
| 280 | + | |
| 281 | + | |
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| |||
319 | 319 |
| |
320 | 320 |
| |
321 | 321 |
| |
322 |
| - | |
323 |
| - | |
324 |
| - | |
325 |
| - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
326 | 326 |
| |
327 | 327 |
| |
328 | 328 |
| |
| |||
344 | 344 |
| |
345 | 345 |
| |
346 | 346 |
| |
347 |
| - | |
348 |
| - | |
349 |
| - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
350 | 350 |
| |
351 | 351 |
| |
352 | 352 |
| |
| |||
481 | 481 |
| |
482 | 482 |
| |
483 | 483 |
| |
484 |
| - | |
485 |
| - | |
486 |
| - | |
| 484 | + | |
| 485 | + |
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 |
| |
11 | 15 |
| |
12 | 16 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 |
| |
12 | 15 |
| |
13 | 16 |
| |
|
Lines changed: 7 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
11 | 10 |
| |
12 |
| - | |
| 11 | + | |
13 | 12 |
| |
14 |
| - | |
15 |
| - | |
16 |
| - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
130 | 131 |
| |
131 | 132 |
| |
132 | 133 |
| |
133 |
| - | |
| 134 | + | |
134 | 135 |
| |
135 | 136 |
| |
136 | 137 |
| |
|
0 commit comments
Comments
(0)