Commit 9bc44e3
committed
Introduce ServicerContext.abort to abort an RPC
gRPC Python required RPCs terminating with non-OK status code to still
return a valid response value after calling set_code, even though the
response value was not supposed to be communicated to the client, and
returning None is considered a programming error.
This commit introduces an alternative mechanism to terminate RPCs by
calling the `abort` method on `ServicerContext` passed to the handler,
which raises an exception and signals to the gRPC runtime to abort the
RPC with the specified status code and details.1 parent 5663eac commit 9bc44e3
3 files changed
Lines changed: 50 additions & 14 deletions
File tree
- src/python
- grpcio_testing/grpc_testing/_server
- grpcio/grpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
837 | 856 | | |
838 | 857 | | |
839 | 858 | | |
840 | 859 | | |
841 | | - | |
842 | | - | |
| 860 | + | |
| 861 | + | |
843 | 862 | | |
844 | | - | |
845 | | - | |
846 | | - | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
847 | 866 | | |
848 | 867 | | |
849 | 868 | | |
850 | 869 | | |
851 | 870 | | |
852 | 871 | | |
853 | | - | |
854 | | - | |
| 872 | + | |
| 873 | + | |
855 | 874 | | |
856 | | - | |
857 | | - | |
858 | | - | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
859 | 879 | | |
860 | 880 | | |
861 | 881 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
276 | 284 | | |
277 | 285 | | |
278 | 286 | | |
| |||
369 | 377 | | |
370 | 378 | | |
371 | 379 | | |
372 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
373 | 384 | | |
374 | 385 | | |
375 | 386 | | |
| |||
384 | 395 | | |
385 | 396 | | |
386 | 397 | | |
387 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
388 | 402 | | |
389 | 403 | | |
390 | 404 | | |
| |||
430 | 444 | | |
431 | 445 | | |
432 | 446 | | |
433 | | - | |
434 | 447 | | |
435 | 448 | | |
436 | 449 | | |
437 | 450 | | |
438 | | - | |
| 451 | + | |
439 | 452 | | |
440 | 453 | | |
441 | 454 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
0 commit comments