Commit 8e791ca
Chris Rossi
EventLoop and tasklets refactor. (#73)
It was found, through working query iterators, that when a TaskletFuture
calls ``_advance_tasklet`` in its done callback, if it calls it
directly, we can get a really deep call stack that eventually reaches
the limit for maximum recursion. This refactors that to add the
``_advance_tasklet`` call to the eventloop to be run soon, rather than
calling it directly, which fixes this issue by keeping the call stack
shallow. The legacy NDB code was actually already using this
indirection and I had changed it to a direct call because I couldn't
figure out why the legacy code didn't just do that, already. I knew
there was a chance that the reason would reveal itself through trial and
error, and it eventually did.
I also performed a minor refactor on the eventloop itself, adding the
``call_soon`` method to handle the case that was previously handled by
passing ``None`` for the ``delay`` argument to ``queue_call``. This just
makes that API a little bit cleaner.1 parent 23c46cf commit 8e791ca
File tree
5 files changed
+61
-42
lines changed- packages/google-cloud-ndb
- src/google/cloud/ndb
- tests
- unit
5 files changed
+61
-42
lines changedLines changed: 24 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 84 | | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
102 | 92 | | |
103 | 93 | | |
104 | 94 | | |
| |||
113 | 103 | | |
114 | 104 | | |
115 | 105 | | |
116 | | - | |
117 | | - | |
| 106 | + | |
118 | 107 | | |
119 | 108 | | |
120 | 109 | | |
| |||
125 | 114 | | |
126 | 115 | | |
127 | 116 | | |
128 | | - | |
| 117 | + | |
| 118 | + | |
129 | 119 | | |
130 | 120 | | |
131 | 121 | | |
| |||
205 | 195 | | |
206 | 196 | | |
207 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | 219 | | |
224 | 220 | | |
225 | 221 | | |
| |||
379 | 375 | | |
380 | 376 | | |
381 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
382 | 384 | | |
383 | 385 | | |
384 | 386 | | |
| |||
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
| 237 | + | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
285 | 283 | | |
286 | 284 | | |
287 | | - | |
| 285 | + | |
288 | 286 | | |
289 | | - | |
| 287 | + | |
290 | 288 | | |
291 | 289 | | |
292 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
79 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
80 | 89 | | |
81 | 90 | | |
82 | 91 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
764 | 764 | | |
765 | 765 | | |
766 | 766 | | |
767 | | - | |
| 767 | + | |
| 768 | + | |
768 | 769 | | |
769 | 770 | | |
770 | 771 | | |
| |||
788 | 789 | | |
789 | 790 | | |
790 | 791 | | |
791 | | - | |
| 792 | + | |
| 793 | + | |
792 | 794 | | |
793 | 795 | | |
794 | 796 | | |
| |||
824 | 826 | | |
825 | 827 | | |
826 | 828 | | |
827 | | - | |
| 829 | + | |
| 830 | + | |
828 | 831 | | |
829 | 832 | | |
830 | 833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
331 | 338 | | |
332 | 339 | | |
333 | 340 | | |
| |||
0 commit comments