Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information