This fixes the current ruby server interop test flakiness.
- The interop tests recently changed so that clients access servers in
parallel, meaning that the interop servers handle multiple rpcs at once,
which is how this bug became visible
- since this change, tests run against the ruby interop server have
failed sporadically
- the problem was that the block in #loop_handle_server_calls that is
passed to the thread pool referenced a var in an enclosing block,
which resulted in requests being processed by the wrong handler
- this fix ensures that the block to be run on the thread pool thread
does not have any references to vars in the enclosing block
- ensures that servers cancels calls after the shutdown timeout
- uses an infinite timeout when request server calls
This two changes fix the issue where the server segfaults on shutdown.
Corrects some other issues
- fixes status return when calls fail by always returning the status
- resolves bidi_call client's failure to return an exception on bad
status by swapping the wait for status to the read thread
* this also improves the cancel_after_first_response test
Also
- adds a unit test that verifies that a bidi call will time out.
- timeout has been a default arg till now
- this switches it to a keyword arg with the same behavior
- in addition, it adds deadline as distinct keyword arg, allowing users
the choice of the idiomatic(timeout) or the aligned(deadline)
- introduces a #wait method on the call operation view
- invokes #wait on a Notifier that is created for all operations
- ensures the Notifier is invoked if necessary whenever a client request
completes
- updates the interop_test to use op.wait before checking if the call
was cancelled.
- stops attempting to verify by catching the CancelledError
- instead the test examines the operation state after cancellation,
which is equally valid and more stable.
Also
- simplifies bidi on the server