Commit 810ded1
Chris Rossi
fix: fix race condition in remote calls (#329)
The wrapper, `_remote.RemoteCall`, added to help attach debugging into
to gRPC calls, inadvertantly introduced a race condition between the
gRPC thread and the NDB thread, where the gRPC thread might call
`RemoteCall._finish` *during* a call to `RemoteCall.add_done_callback`.
The solution, here, is to turn `RemoteCall.add_done_callback` into a
direct pass-through to `grpc.Future.add_done_callback` on the wrapped
future. The callback which is eventually executed in the gRPC thread,
only pushes the finished RPC onto a `queue.Queue` which is eventually
consumed by the event loop running in the NDB thread.
Fixes #302.1 parent 30d15da commit 810ded1
1 file changed
+8
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
49 | 46 | | |
50 | | - | |
| 47 | + | |
51 | 48 | | |
52 | 49 | | |
53 | 50 | | |
| |||
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | | - | |
| 57 | + | |
61 | 58 | | |
62 | 59 | | |
63 | 60 | | |
| |||
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
0 commit comments