api.html 137 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>API Reference &#8212; gRPC Python 1.17.0.dev0 documentation</title>
  8. <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
  9. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  10. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  11. <script type="text/javascript" src="_static/jquery.js"></script>
  12. <script type="text/javascript" src="_static/underscore.js"></script>
  13. <script type="text/javascript" src="_static/doctools.js"></script>
  14. <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  15. <link rel="index" title="Index" href="genindex.html" />
  16. <link rel="search" title="Search" href="search.html" />
  17. <link rel="next" title="gRPC Health Checking" href="grpc_health_checking.html" />
  18. <link rel="prev" title="Welcome to gRPC Python’s documentation!" href="index.html" />
  19. <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  20. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  21. </head><body>
  22. <div class="document">
  23. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  24. <div class="sphinxsidebarwrapper">
  25. <h1 class="logo"><a href="index.html">gRPC Python</a></h1>
  26. <p class="blurb">1.17.0.dev0</p>
  27. <h3>Navigation</h3>
  28. <p class="caption"><span class="caption-text">Contents:</span></p>
  29. <ul class="current">
  30. <li class="toctree-l1 current"><a class="current reference internal" href="#">API Reference</a><ul>
  31. <li class="toctree-l2"><a class="reference internal" href="#create-client">Create Client</a></li>
  32. <li class="toctree-l2"><a class="reference internal" href="#create-client-credentials">Create Client Credentials</a></li>
  33. <li class="toctree-l2"><a class="reference internal" href="#create-server">Create Server</a></li>
  34. <li class="toctree-l2"><a class="reference internal" href="#create-server-credentials">Create Server Credentials</a></li>
  35. <li class="toctree-l2"><a class="reference internal" href="#rpc-method-handlers">RPC Method Handlers</a></li>
  36. <li class="toctree-l2"><a class="reference internal" href="#channel-ready-future">Channel Ready Future</a></li>
  37. <li class="toctree-l2"><a class="reference internal" href="#channel-connectivity">Channel Connectivity</a></li>
  38. <li class="toctree-l2"><a class="reference internal" href="#grpc-status-code">gRPC Status Code</a></li>
  39. <li class="toctree-l2"><a class="reference internal" href="#channel-object">Channel Object</a></li>
  40. <li class="toctree-l2"><a class="reference internal" href="#server-object">Server Object</a></li>
  41. <li class="toctree-l2"><a class="reference internal" href="#authentication-authorization-objects">Authentication &amp; Authorization Objects</a></li>
  42. <li class="toctree-l2"><a class="reference internal" href="#grpc-exceptions">gRPC Exceptions</a></li>
  43. <li class="toctree-l2"><a class="reference internal" href="#shared-context">Shared Context</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="#client-side-context">Client-Side Context</a></li>
  45. <li class="toctree-l2"><a class="reference internal" href="#client-side-interceptor">Client-Side Interceptor</a></li>
  46. <li class="toctree-l2"><a class="reference internal" href="#service-side-context">Service-Side Context</a></li>
  47. <li class="toctree-l2"><a class="reference internal" href="#service-side-handler">Service-Side Handler</a></li>
  48. <li class="toctree-l2"><a class="reference internal" href="#service-side-interceptor">Service-Side Interceptor</a></li>
  49. <li class="toctree-l2"><a class="reference internal" href="#multi-callable">Multi-Callable</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="#future">Future</a></li>
  51. </ul>
  52. </li>
  53. <li class="toctree-l1"><a class="reference internal" href="grpc_health_checking.html">gRPC Health Checking</a></li>
  54. <li class="toctree-l1"><a class="reference internal" href="grpc_reflection.html">gRPC Reflection</a></li>
  55. <li class="toctree-l1"><a class="reference internal" href="grpc_testing.html">gRPC Testing</a></li>
  56. <li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
  57. </ul>
  58. <div class="relations">
  59. <h3>Related Topics</h3>
  60. <ul>
  61. <li><a href="index.html">Documentation overview</a><ul>
  62. <li>Previous: <a href="index.html" title="previous chapter">Welcome to gRPC Python’s documentation!</a></li>
  63. <li>Next: <a href="grpc_health_checking.html" title="next chapter">gRPC Health Checking</a></li>
  64. </ul></li>
  65. </ul>
  66. </div>
  67. <div id="searchbox" style="display: none" role="search">
  68. <h3>Quick search</h3>
  69. <div class="searchformwrapper">
  70. <form class="search" action="search.html" method="get">
  71. <input type="text" name="q" />
  72. <input type="submit" value="Go" />
  73. <input type="hidden" name="check_keywords" value="yes" />
  74. <input type="hidden" name="area" value="default" />
  75. </form>
  76. </div>
  77. </div>
  78. <script type="text/javascript">$('#searchbox').show(0);</script>
  79. </div>
  80. </div>
  81. <div class="documentwrapper">
  82. <div class="bodywrapper">
  83. <div class="body" role="main">
  84. <div class="section" id="module-grpc">
  85. <span id="api-reference"></span><h1>API Reference<a class="headerlink" href="#module-grpc" title="Permalink to this headline">¶</a></h1>
  86. <div class="section" id="create-client">
  87. <h2>Create Client<a class="headerlink" href="#create-client" title="Permalink to this headline">¶</a></h2>
  88. <dl class="function">
  89. <dt id="grpc.insecure_channel">
  90. <code class="descclassname">grpc.</code><code class="descname">insecure_channel</code><span class="sig-paren">(</span><em>target</em>, <em>options=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#insecure_channel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.insecure_channel" title="Permalink to this definition">¶</a></dt>
  91. <dd><p>Creates an insecure Channel to a server.</p>
  92. <p>The returned Channel is thread-safe.</p>
  93. <table class="docutils field-list" frame="void" rules="none">
  94. <col class="field-name" />
  95. <col class="field-body" />
  96. <tbody valign="top">
  97. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  98. <li><strong>target</strong> – The server address</li>
  99. <li><strong>options</strong> – An optional list of key-value pairs (channel args
  100. in gRPC Core runtime) to configure the channel.</li>
  101. </ul>
  102. </td>
  103. </tr>
  104. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A Channel.</p>
  105. </td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. </dd></dl>
  110. <dl class="function">
  111. <dt id="grpc.secure_channel">
  112. <code class="descclassname">grpc.</code><code class="descname">secure_channel</code><span class="sig-paren">(</span><em>target</em>, <em>credentials</em>, <em>options=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#secure_channel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.secure_channel" title="Permalink to this definition">¶</a></dt>
  113. <dd><p>Creates a secure Channel to a server.</p>
  114. <p>The returned Channel is thread-safe.</p>
  115. <table class="docutils field-list" frame="void" rules="none">
  116. <col class="field-name" />
  117. <col class="field-body" />
  118. <tbody valign="top">
  119. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  120. <li><strong>target</strong> – The server address.</li>
  121. <li><strong>credentials</strong> – A ChannelCredentials instance.</li>
  122. <li><strong>options</strong> – An optional list of key-value pairs (channel args
  123. in gRPC Core runtime) to configure the channel.</li>
  124. </ul>
  125. </td>
  126. </tr>
  127. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A Channel.</p>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. </dd></dl>
  133. <dl class="function">
  134. <dt id="grpc.intercept_channel">
  135. <code class="descclassname">grpc.</code><code class="descname">intercept_channel</code><span class="sig-paren">(</span><em>channel</em>, <em>*interceptors</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#intercept_channel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.intercept_channel" title="Permalink to this definition">¶</a></dt>
  136. <dd><p>Intercepts a channel through a set of interceptors.</p>
  137. <p>This is an EXPERIMENTAL API.</p>
  138. <table class="docutils field-list" frame="void" rules="none">
  139. <col class="field-name" />
  140. <col class="field-body" />
  141. <tbody valign="top">
  142. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  143. <li><strong>channel</strong> – A Channel.</li>
  144. <li><strong>interceptors</strong> – Zero or more objects of type
  145. UnaryUnaryClientInterceptor,
  146. UnaryStreamClientInterceptor,
  147. StreamUnaryClientInterceptor, or
  148. StreamStreamClientInterceptor.
  149. Interceptors are given control in the order they are listed.</li>
  150. </ul>
  151. </td>
  152. </tr>
  153. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A Channel that intercepts each invocation via the provided interceptors.</p>
  154. </td>
  155. </tr>
  156. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code> – If interceptor does not derive from any of
  157. UnaryUnaryClientInterceptor,
  158. UnaryStreamClientInterceptor,
  159. StreamUnaryClientInterceptor, or
  160. StreamStreamClientInterceptor.</p>
  161. </td>
  162. </tr>
  163. </tbody>
  164. </table>
  165. </dd></dl>
  166. </div>
  167. <div class="section" id="create-client-credentials">
  168. <h2>Create Client Credentials<a class="headerlink" href="#create-client-credentials" title="Permalink to this headline">¶</a></h2>
  169. <dl class="function">
  170. <dt id="grpc.ssl_channel_credentials">
  171. <code class="descclassname">grpc.</code><code class="descname">ssl_channel_credentials</code><span class="sig-paren">(</span><em>root_certificates=None</em>, <em>private_key=None</em>, <em>certificate_chain=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ssl_channel_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ssl_channel_credentials" title="Permalink to this definition">¶</a></dt>
  172. <dd><p>Creates a ChannelCredentials for use with an SSL-enabled Channel.</p>
  173. <table class="docutils field-list" frame="void" rules="none">
  174. <col class="field-name" />
  175. <col class="field-body" />
  176. <tbody valign="top">
  177. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  178. <li><strong>root_certificates</strong> – The PEM-encoded root certificates as a byte string,
  179. or None to retrieve them from a default location chosen by gRPC
  180. runtime.</li>
  181. <li><strong>private_key</strong> – The PEM-encoded private key as a byte string, or None if no
  182. private key should be used.</li>
  183. <li><strong>certificate_chain</strong> – The PEM-encoded certificate chain as a byte string
  184. to use or or None if no certificate chain should be used.</li>
  185. </ul>
  186. </td>
  187. </tr>
  188. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A ChannelCredentials for use with an SSL-enabled Channel.</p>
  189. </td>
  190. </tr>
  191. </tbody>
  192. </table>
  193. </dd></dl>
  194. <dl class="function">
  195. <dt id="grpc.metadata_call_credentials">
  196. <code class="descclassname">grpc.</code><code class="descname">metadata_call_credentials</code><span class="sig-paren">(</span><em>metadata_plugin</em>, <em>name=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#metadata_call_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.metadata_call_credentials" title="Permalink to this definition">¶</a></dt>
  197. <dd><p>Construct CallCredentials from an AuthMetadataPlugin.</p>
  198. <table class="docutils field-list" frame="void" rules="none">
  199. <col class="field-name" />
  200. <col class="field-body" />
  201. <tbody valign="top">
  202. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  203. <li><strong>metadata_plugin</strong> – An AuthMetadataPlugin to use for authentication.</li>
  204. <li><strong>name</strong> – An optional name for the plugin.</li>
  205. </ul>
  206. </td>
  207. </tr>
  208. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A CallCredentials.</p>
  209. </td>
  210. </tr>
  211. </tbody>
  212. </table>
  213. </dd></dl>
  214. <dl class="function">
  215. <dt id="grpc.access_token_call_credentials">
  216. <code class="descclassname">grpc.</code><code class="descname">access_token_call_credentials</code><span class="sig-paren">(</span><em>access_token</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#access_token_call_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.access_token_call_credentials" title="Permalink to this definition">¶</a></dt>
  217. <dd><p>Construct CallCredentials from an access token.</p>
  218. <table class="docutils field-list" frame="void" rules="none">
  219. <col class="field-name" />
  220. <col class="field-body" />
  221. <tbody valign="top">
  222. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>access_token</strong> – A string to place directly in the http request
  223. authorization header, for example
  224. “authorization: Bearer &lt;access_token&gt;”.</td>
  225. </tr>
  226. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A CallCredentials.</td>
  227. </tr>
  228. </tbody>
  229. </table>
  230. </dd></dl>
  231. <dl class="function">
  232. <dt id="grpc.composite_call_credentials">
  233. <code class="descclassname">grpc.</code><code class="descname">composite_call_credentials</code><span class="sig-paren">(</span><em>*call_credentials</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#composite_call_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.composite_call_credentials" title="Permalink to this definition">¶</a></dt>
  234. <dd><p>Compose multiple CallCredentials to make a new CallCredentials.</p>
  235. <table class="docutils field-list" frame="void" rules="none">
  236. <col class="field-name" />
  237. <col class="field-body" />
  238. <tbody valign="top">
  239. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>*call_credentials</strong> – At least two CallCredentials objects.</td>
  240. </tr>
  241. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A CallCredentials object composed of the given CallCredentials objects.</td>
  242. </tr>
  243. </tbody>
  244. </table>
  245. </dd></dl>
  246. <dl class="function">
  247. <dt id="grpc.composite_channel_credentials">
  248. <code class="descclassname">grpc.</code><code class="descname">composite_channel_credentials</code><span class="sig-paren">(</span><em>channel_credentials</em>, <em>*call_credentials</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#composite_channel_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.composite_channel_credentials" title="Permalink to this definition">¶</a></dt>
  249. <dd><p>Compose a ChannelCredentials and one or more CallCredentials objects.</p>
  250. <table class="docutils field-list" frame="void" rules="none">
  251. <col class="field-name" />
  252. <col class="field-body" />
  253. <tbody valign="top">
  254. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  255. <li><strong>channel_credentials</strong> – A ChannelCredentials object.</li>
  256. <li><strong>*call_credentials</strong> – One or more CallCredentials objects.</li>
  257. </ul>
  258. </td>
  259. </tr>
  260. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><dl class="docutils">
  261. <dt>A ChannelCredentials composed of the given ChannelCredentials and</dt>
  262. <dd><p class="first last">CallCredentials objects.</p>
  263. </dd>
  264. </dl>
  265. </p>
  266. </td>
  267. </tr>
  268. </tbody>
  269. </table>
  270. </dd></dl>
  271. </div>
  272. <div class="section" id="create-server">
  273. <h2>Create Server<a class="headerlink" href="#create-server" title="Permalink to this headline">¶</a></h2>
  274. <dl class="function">
  275. <dt id="grpc.server">
  276. <code class="descclassname">grpc.</code><code class="descname">server</code><span class="sig-paren">(</span><em>thread_pool</em>, <em>handlers=None</em>, <em>interceptors=None</em>, <em>options=None</em>, <em>maximum_concurrent_rpcs=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#server"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.server" title="Permalink to this definition">¶</a></dt>
  277. <dd><p>Creates a Server with which RPCs can be serviced.</p>
  278. <table class="docutils field-list" frame="void" rules="none">
  279. <col class="field-name" />
  280. <col class="field-body" />
  281. <tbody valign="top">
  282. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  283. <li><strong>thread_pool</strong> – A futures.ThreadPoolExecutor to be used by the Server
  284. to execute RPC handlers.</li>
  285. <li><strong>handlers</strong> – An optional list of GenericRpcHandlers used for executing RPCs.
  286. More handlers may be added by calling add_generic_rpc_handlers any time
  287. before the server is started.</li>
  288. <li><strong>interceptors</strong> – An optional list of ServerInterceptor objects that observe
  289. and optionally manipulate the incoming RPCs before handing them over to
  290. handlers. The interceptors are given control in the order they are
  291. specified. This is an EXPERIMENTAL API.</li>
  292. <li><strong>options</strong> – An optional list of key-value pairs (channel args in gRPC runtime)</li>
  293. <li><strong>configure the channel.</strong> (<em>to</em>) – </li>
  294. <li><strong>maximum_concurrent_rpcs</strong> – The maximum number of concurrent RPCs this server
  295. will service before returning RESOURCE_EXHAUSTED status, or None to
  296. indicate no limit.</li>
  297. </ul>
  298. </td>
  299. </tr>
  300. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A Server object.</p>
  301. </td>
  302. </tr>
  303. </tbody>
  304. </table>
  305. </dd></dl>
  306. </div>
  307. <div class="section" id="create-server-credentials">
  308. <h2>Create Server Credentials<a class="headerlink" href="#create-server-credentials" title="Permalink to this headline">¶</a></h2>
  309. <dl class="function">
  310. <dt id="grpc.ssl_server_credentials">
  311. <code class="descclassname">grpc.</code><code class="descname">ssl_server_credentials</code><span class="sig-paren">(</span><em>private_key_certificate_chain_pairs</em>, <em>root_certificates=None</em>, <em>require_client_auth=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ssl_server_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ssl_server_credentials" title="Permalink to this definition">¶</a></dt>
  312. <dd><p>Creates a ServerCredentials for use with an SSL-enabled Server.</p>
  313. <table class="docutils field-list" frame="void" rules="none">
  314. <col class="field-name" />
  315. <col class="field-body" />
  316. <tbody valign="top">
  317. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  318. <li><strong>private_key_certificate_chain_pairs</strong> – A list of pairs of the form
  319. [PEM-encoded private key, PEM-encoded certificate chain].</li>
  320. <li><strong>root_certificates</strong> – An optional byte string of PEM-encoded client root
  321. certificates that the server will use to verify client authentication.
  322. If omitted, require_client_auth must also be False.</li>
  323. <li><strong>require_client_auth</strong> – A boolean indicating whether or not to require
  324. clients to be authenticated. May only be True if root_certificates
  325. is not None.</li>
  326. </ul>
  327. </td>
  328. </tr>
  329. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A ServerCredentials for use with an SSL-enabled Server. Typically, this
  330. object is an argument to add_secure_port() method during server setup.</p>
  331. </td>
  332. </tr>
  333. </tbody>
  334. </table>
  335. </dd></dl>
  336. <dl class="function">
  337. <dt id="grpc.ssl_server_certificate_configuration">
  338. <code class="descclassname">grpc.</code><code class="descname">ssl_server_certificate_configuration</code><span class="sig-paren">(</span><em>private_key_certificate_chain_pairs</em>, <em>root_certificates=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ssl_server_certificate_configuration"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ssl_server_certificate_configuration" title="Permalink to this definition">¶</a></dt>
  339. <dd><p>Creates a ServerCertificateConfiguration for use with a Server.</p>
  340. <table class="docutils field-list" frame="void" rules="none">
  341. <col class="field-name" />
  342. <col class="field-body" />
  343. <tbody valign="top">
  344. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  345. <li><strong>private_key_certificate_chain_pairs</strong> – A collection of pairs of
  346. the form [PEM-encoded private key, PEM-encoded certificate
  347. chain].</li>
  348. <li><strong>root_certificates</strong> – An optional byte string of PEM-encoded client root
  349. certificates that the server will use to verify client authentication.</li>
  350. </ul>
  351. </td>
  352. </tr>
  353. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><dl class="docutils">
  354. <dt>A ServerCertificateConfiguration that can be returned in the certificate</dt>
  355. <dd><p class="first last">configuration fetching callback.</p>
  356. </dd>
  357. </dl>
  358. </p>
  359. </td>
  360. </tr>
  361. </tbody>
  362. </table>
  363. </dd></dl>
  364. <dl class="function">
  365. <dt id="grpc.dynamic_ssl_server_credentials">
  366. <code class="descclassname">grpc.</code><code class="descname">dynamic_ssl_server_credentials</code><span class="sig-paren">(</span><em>initial_certificate_configuration</em>, <em>certificate_configuration_fetcher</em>, <em>require_client_authentication=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#dynamic_ssl_server_credentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.dynamic_ssl_server_credentials" title="Permalink to this definition">¶</a></dt>
  367. <dd><p>Creates a ServerCredentials for use with an SSL-enabled Server.</p>
  368. <table class="docutils field-list" frame="void" rules="none">
  369. <col class="field-name" />
  370. <col class="field-body" />
  371. <tbody valign="top">
  372. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  373. <li><strong>initial_certificate_configuration</strong> (<a class="reference internal" href="#grpc.ServerCertificateConfiguration" title="grpc.ServerCertificateConfiguration"><em>ServerCertificateConfiguration</em></a>) – The
  374. certificate configuration with which the server will be initialized.</li>
  375. <li><strong>certificate_configuration_fetcher</strong> (<em>callable</em>) – A callable that takes no
  376. arguments and should return a ServerCertificateConfiguration to
  377. replace the server’s current certificate, or None for no change
  378. (i.e., the server will continue its current certificate
  379. config). The library will call this callback on <em>every</em> new
  380. client connection before starting the TLS handshake with the
  381. client, thus allowing the user application to optionally
  382. return a new ServerCertificateConfiguration that the server will then
  383. use for the handshake.</li>
  384. <li><strong>require_client_authentication</strong> – A boolean indicating whether or not to
  385. require clients to be authenticated.</li>
  386. </ul>
  387. </td>
  388. </tr>
  389. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A ServerCredentials.</p>
  390. </td>
  391. </tr>
  392. </tbody>
  393. </table>
  394. </dd></dl>
  395. </div>
  396. <div class="section" id="rpc-method-handlers">
  397. <h2>RPC Method Handlers<a class="headerlink" href="#rpc-method-handlers" title="Permalink to this headline">¶</a></h2>
  398. <dl class="function">
  399. <dt id="grpc.unary_unary_rpc_method_handler">
  400. <code class="descclassname">grpc.</code><code class="descname">unary_unary_rpc_method_handler</code><span class="sig-paren">(</span><em>behavior</em>, <em>request_deserializer=None</em>, <em>response_serializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#unary_unary_rpc_method_handler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.unary_unary_rpc_method_handler" title="Permalink to this definition">¶</a></dt>
  401. <dd><p>Creates an RpcMethodHandler for a unary-unary RPC method.</p>
  402. <table class="docutils field-list" frame="void" rules="none">
  403. <col class="field-name" />
  404. <col class="field-body" />
  405. <tbody valign="top">
  406. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  407. <li><strong>behavior</strong> – The implementation of an RPC that accepts one request
  408. and returns one response.</li>
  409. <li><strong>request_deserializer</strong> – An optional behavior for request deserialization.</li>
  410. <li><strong>response_serializer</strong> – An optional behavior for response serialization.</li>
  411. </ul>
  412. </td>
  413. </tr>
  414. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An RpcMethodHandler object that is typically used by grpc.Server.</p>
  415. </td>
  416. </tr>
  417. </tbody>
  418. </table>
  419. </dd></dl>
  420. <dl class="function">
  421. <dt id="grpc.unary_stream_rpc_method_handler">
  422. <code class="descclassname">grpc.</code><code class="descname">unary_stream_rpc_method_handler</code><span class="sig-paren">(</span><em>behavior</em>, <em>request_deserializer=None</em>, <em>response_serializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#unary_stream_rpc_method_handler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.unary_stream_rpc_method_handler" title="Permalink to this definition">¶</a></dt>
  423. <dd><p>Creates an RpcMethodHandler for a unary-stream RPC method.</p>
  424. <table class="docutils field-list" frame="void" rules="none">
  425. <col class="field-name" />
  426. <col class="field-body" />
  427. <tbody valign="top">
  428. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  429. <li><strong>behavior</strong> – The implementation of an RPC that accepts one request
  430. and returns an iterator of response values.</li>
  431. <li><strong>request_deserializer</strong> – An optional behavior for request deserialization.</li>
  432. <li><strong>response_serializer</strong> – An optional behavior for response serialization.</li>
  433. </ul>
  434. </td>
  435. </tr>
  436. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An RpcMethodHandler object that is typically used by grpc.Server.</p>
  437. </td>
  438. </tr>
  439. </tbody>
  440. </table>
  441. </dd></dl>
  442. <dl class="function">
  443. <dt id="grpc.stream_unary_rpc_method_handler">
  444. <code class="descclassname">grpc.</code><code class="descname">stream_unary_rpc_method_handler</code><span class="sig-paren">(</span><em>behavior</em>, <em>request_deserializer=None</em>, <em>response_serializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#stream_unary_rpc_method_handler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.stream_unary_rpc_method_handler" title="Permalink to this definition">¶</a></dt>
  445. <dd><p>Creates an RpcMethodHandler for a stream-unary RPC method.</p>
  446. <table class="docutils field-list" frame="void" rules="none">
  447. <col class="field-name" />
  448. <col class="field-body" />
  449. <tbody valign="top">
  450. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  451. <li><strong>behavior</strong> – The implementation of an RPC that accepts an iterator of
  452. request values and returns a single response value.</li>
  453. <li><strong>request_deserializer</strong> – An optional behavior for request deserialization.</li>
  454. <li><strong>response_serializer</strong> – An optional behavior for response serialization.</li>
  455. </ul>
  456. </td>
  457. </tr>
  458. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An RpcMethodHandler object that is typically used by grpc.Server.</p>
  459. </td>
  460. </tr>
  461. </tbody>
  462. </table>
  463. </dd></dl>
  464. <dl class="function">
  465. <dt id="grpc.stream_stream_rpc_method_handler">
  466. <code class="descclassname">grpc.</code><code class="descname">stream_stream_rpc_method_handler</code><span class="sig-paren">(</span><em>behavior</em>, <em>request_deserializer=None</em>, <em>response_serializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#stream_stream_rpc_method_handler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.stream_stream_rpc_method_handler" title="Permalink to this definition">¶</a></dt>
  467. <dd><p>Creates an RpcMethodHandler for a stream-stream RPC method.</p>
  468. <table class="docutils field-list" frame="void" rules="none">
  469. <col class="field-name" />
  470. <col class="field-body" />
  471. <tbody valign="top">
  472. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  473. <li><strong>behavior</strong> – The implementation of an RPC that accepts an iterator of
  474. request values and returns an iterator of response values.</li>
  475. <li><strong>request_deserializer</strong> – An optional behavior for request deserialization.</li>
  476. <li><strong>response_serializer</strong> – An optional behavior for response serialization.</li>
  477. </ul>
  478. </td>
  479. </tr>
  480. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An RpcMethodHandler object that is typically used by grpc.Server.</p>
  481. </td>
  482. </tr>
  483. </tbody>
  484. </table>
  485. </dd></dl>
  486. <dl class="function">
  487. <dt id="grpc.method_handlers_generic_handler">
  488. <code class="descclassname">grpc.</code><code class="descname">method_handlers_generic_handler</code><span class="sig-paren">(</span><em>service</em>, <em>method_handlers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#method_handlers_generic_handler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.method_handlers_generic_handler" title="Permalink to this definition">¶</a></dt>
  489. <dd><p>Creates a GenericRpcHandler from RpcMethodHandlers.</p>
  490. <table class="docutils field-list" frame="void" rules="none">
  491. <col class="field-name" />
  492. <col class="field-body" />
  493. <tbody valign="top">
  494. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  495. <li><strong>service</strong> – The name of the service that is implemented by the
  496. method_handlers.</li>
  497. <li><strong>method_handlers</strong> – A dictionary that maps method names to corresponding
  498. RpcMethodHandler.</li>
  499. </ul>
  500. </td>
  501. </tr>
  502. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A GenericRpcHandler. This is typically added to the grpc.Server object
  503. with add_generic_rpc_handlers() before starting the server.</p>
  504. </td>
  505. </tr>
  506. </tbody>
  507. </table>
  508. </dd></dl>
  509. </div>
  510. <div class="section" id="channel-ready-future">
  511. <h2>Channel Ready Future<a class="headerlink" href="#channel-ready-future" title="Permalink to this headline">¶</a></h2>
  512. <dl class="function">
  513. <dt id="grpc.channel_ready_future">
  514. <code class="descclassname">grpc.</code><code class="descname">channel_ready_future</code><span class="sig-paren">(</span><em>channel</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#channel_ready_future"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.channel_ready_future" title="Permalink to this definition">¶</a></dt>
  515. <dd><p>Creates a Future that tracks when a Channel is ready.</p>
  516. <p>Cancelling the Future does not affect the channel’s state machine.
  517. It merely decouples the Future from channel state machine.</p>
  518. <table class="docutils field-list" frame="void" rules="none">
  519. <col class="field-name" />
  520. <col class="field-body" />
  521. <tbody valign="top">
  522. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>channel</strong> – A Channel object.</td>
  523. </tr>
  524. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A Future object that matures when the channel connectivity is
  525. ChannelConnectivity.READY.</td>
  526. </tr>
  527. </tbody>
  528. </table>
  529. </dd></dl>
  530. </div>
  531. <div class="section" id="channel-connectivity">
  532. <h2>Channel Connectivity<a class="headerlink" href="#channel-connectivity" title="Permalink to this headline">¶</a></h2>
  533. <dl class="class">
  534. <dt id="grpc.ChannelConnectivity">
  535. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ChannelConnectivity</code><a class="reference internal" href="_modules/grpc.html#ChannelConnectivity"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ChannelConnectivity" title="Permalink to this definition">¶</a></dt>
  536. <dd><p>Mirrors grpc_connectivity_state in the gRPC Core.</p>
  537. <dl class="attribute">
  538. <dt id="grpc.ChannelConnectivity.IDLE">
  539. <code class="descname">IDLE</code><a class="headerlink" href="#grpc.ChannelConnectivity.IDLE" title="Permalink to this definition">¶</a></dt>
  540. <dd><p>The channel is idle.</p>
  541. </dd></dl>
  542. <dl class="attribute">
  543. <dt id="grpc.ChannelConnectivity.CONNECTING">
  544. <code class="descname">CONNECTING</code><a class="headerlink" href="#grpc.ChannelConnectivity.CONNECTING" title="Permalink to this definition">¶</a></dt>
  545. <dd><p>The channel is connecting.</p>
  546. </dd></dl>
  547. <dl class="attribute">
  548. <dt id="grpc.ChannelConnectivity.READY">
  549. <code class="descname">READY</code><a class="headerlink" href="#grpc.ChannelConnectivity.READY" title="Permalink to this definition">¶</a></dt>
  550. <dd><p>The channel is ready to conduct RPCs.</p>
  551. </dd></dl>
  552. <dl class="attribute">
  553. <dt id="grpc.ChannelConnectivity.TRANSIENT_FAILURE">
  554. <code class="descname">TRANSIENT_FAILURE</code><a class="headerlink" href="#grpc.ChannelConnectivity.TRANSIENT_FAILURE" title="Permalink to this definition">¶</a></dt>
  555. <dd><p>The channel has seen a failure from which it expects
  556. to recover.</p>
  557. </dd></dl>
  558. <dl class="attribute">
  559. <dt id="grpc.ChannelConnectivity.SHUTDOWN">
  560. <code class="descname">SHUTDOWN</code><a class="headerlink" href="#grpc.ChannelConnectivity.SHUTDOWN" title="Permalink to this definition">¶</a></dt>
  561. <dd><p>The channel has seen a failure from which it cannot recover.</p>
  562. </dd></dl>
  563. </dd></dl>
  564. </div>
  565. <div class="section" id="grpc-status-code">
  566. <h2>gRPC Status Code<a class="headerlink" href="#grpc-status-code" title="Permalink to this headline">¶</a></h2>
  567. <dl class="class">
  568. <dt id="grpc.StatusCode">
  569. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">StatusCode</code><a class="reference internal" href="_modules/grpc.html#StatusCode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StatusCode" title="Permalink to this definition">¶</a></dt>
  570. <dd><p>Mirrors grpc_status_code in the gRPC Core.</p>
  571. <dl class="attribute">
  572. <dt id="grpc.StatusCode.OK">
  573. <code class="descname">OK</code><a class="headerlink" href="#grpc.StatusCode.OK" title="Permalink to this definition">¶</a></dt>
  574. <dd><p>Not an error; returned on success</p>
  575. </dd></dl>
  576. <dl class="attribute">
  577. <dt id="grpc.StatusCode.CANCELLED">
  578. <code class="descname">CANCELLED</code><a class="headerlink" href="#grpc.StatusCode.CANCELLED" title="Permalink to this definition">¶</a></dt>
  579. <dd><p>The operation was cancelled (typically by the caller).</p>
  580. </dd></dl>
  581. <dl class="attribute">
  582. <dt id="grpc.StatusCode.UNKNOWN">
  583. <code class="descname">UNKNOWN</code><a class="headerlink" href="#grpc.StatusCode.UNKNOWN" title="Permalink to this definition">¶</a></dt>
  584. <dd><p>Unknown error.</p>
  585. </dd></dl>
  586. <dl class="attribute">
  587. <dt id="grpc.StatusCode.INVALID_ARGUMENT">
  588. <code class="descname">INVALID_ARGUMENT</code><a class="headerlink" href="#grpc.StatusCode.INVALID_ARGUMENT" title="Permalink to this definition">¶</a></dt>
  589. <dd><p>Client specified an invalid argument.</p>
  590. </dd></dl>
  591. <dl class="attribute">
  592. <dt id="grpc.StatusCode.DEADLINE_EXCEEDED">
  593. <code class="descname">DEADLINE_EXCEEDED</code><a class="headerlink" href="#grpc.StatusCode.DEADLINE_EXCEEDED" title="Permalink to this definition">¶</a></dt>
  594. <dd><p>Deadline expired before operation could complete.</p>
  595. </dd></dl>
  596. <dl class="attribute">
  597. <dt id="grpc.StatusCode.NOT_FOUND">
  598. <code class="descname">NOT_FOUND</code><a class="headerlink" href="#grpc.StatusCode.NOT_FOUND" title="Permalink to this definition">¶</a></dt>
  599. <dd><p>Some requested entity (e.g., file or directory) was not found.</p>
  600. </dd></dl>
  601. <dl class="attribute">
  602. <dt id="grpc.StatusCode.ALREADY_EXISTS">
  603. <code class="descname">ALREADY_EXISTS</code><a class="headerlink" href="#grpc.StatusCode.ALREADY_EXISTS" title="Permalink to this definition">¶</a></dt>
  604. <dd><p>Some entity that we attempted to create (e.g., file or directory)
  605. already exists.</p>
  606. </dd></dl>
  607. <dl class="attribute">
  608. <dt id="grpc.StatusCode.PERMISSION_DENIED">
  609. <code class="descname">PERMISSION_DENIED</code><a class="headerlink" href="#grpc.StatusCode.PERMISSION_DENIED" title="Permalink to this definition">¶</a></dt>
  610. <dd><p>The caller does not have permission to execute the specified
  611. operation.</p>
  612. </dd></dl>
  613. <dl class="attribute">
  614. <dt id="grpc.StatusCode.UNAUTHENTICATED">
  615. <code class="descname">UNAUTHENTICATED</code><a class="headerlink" href="#grpc.StatusCode.UNAUTHENTICATED" title="Permalink to this definition">¶</a></dt>
  616. <dd><p>The request does not have valid authentication credentials for the
  617. operation.</p>
  618. </dd></dl>
  619. <dl class="attribute">
  620. <dt id="grpc.StatusCode.RESOURCE_EXHAUSTED">
  621. <code class="descname">RESOURCE_EXHAUSTED</code><a class="headerlink" href="#grpc.StatusCode.RESOURCE_EXHAUSTED" title="Permalink to this definition">¶</a></dt>
  622. <dd><p>Some resource has been exhausted, perhaps a per-user quota, or
  623. perhaps the entire file system is out of space.</p>
  624. </dd></dl>
  625. <dl class="attribute">
  626. <dt id="grpc.StatusCode.FAILED_PRECONDITION">
  627. <code class="descname">FAILED_PRECONDITION</code><a class="headerlink" href="#grpc.StatusCode.FAILED_PRECONDITION" title="Permalink to this definition">¶</a></dt>
  628. <dd><p>Operation was rejected because the system is not in a state
  629. required for the operation’s execution.</p>
  630. </dd></dl>
  631. <dl class="attribute">
  632. <dt id="grpc.StatusCode.ABORTED">
  633. <code class="descname">ABORTED</code><a class="headerlink" href="#grpc.StatusCode.ABORTED" title="Permalink to this definition">¶</a></dt>
  634. <dd><p>The operation was aborted, typically due to a concurrency issue
  635. like sequencer check failures, transaction aborts, etc.</p>
  636. </dd></dl>
  637. <dl class="attribute">
  638. <dt id="grpc.StatusCode.UNIMPLEMENTED">
  639. <code class="descname">UNIMPLEMENTED</code><a class="headerlink" href="#grpc.StatusCode.UNIMPLEMENTED" title="Permalink to this definition">¶</a></dt>
  640. <dd><p>Operation is not implemented or not supported/enabled in this service.</p>
  641. </dd></dl>
  642. <dl class="attribute">
  643. <dt id="grpc.StatusCode.INTERNAL">
  644. <code class="descname">INTERNAL</code><a class="headerlink" href="#grpc.StatusCode.INTERNAL" title="Permalink to this definition">¶</a></dt>
  645. <dd><p>Internal errors. Means some invariants expected by underlying
  646. system has been broken.</p>
  647. </dd></dl>
  648. <dl class="attribute">
  649. <dt id="grpc.StatusCode.UNAVAILABLE">
  650. <code class="descname">UNAVAILABLE</code><a class="headerlink" href="#grpc.StatusCode.UNAVAILABLE" title="Permalink to this definition">¶</a></dt>
  651. <dd><p>The service is currently unavailable.</p>
  652. </dd></dl>
  653. <dl class="attribute">
  654. <dt id="grpc.StatusCode.DATA_LOSS">
  655. <code class="descname">DATA_LOSS</code><a class="headerlink" href="#grpc.StatusCode.DATA_LOSS" title="Permalink to this definition">¶</a></dt>
  656. <dd><p>Unrecoverable data loss or corruption.</p>
  657. </dd></dl>
  658. </dd></dl>
  659. </div>
  660. <div class="section" id="channel-object">
  661. <h2>Channel Object<a class="headerlink" href="#channel-object" title="Permalink to this headline">¶</a></h2>
  662. <dl class="class">
  663. <dt id="grpc.Channel">
  664. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">Channel</code><a class="reference internal" href="_modules/grpc.html#Channel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel" title="Permalink to this definition">¶</a></dt>
  665. <dd><p>Affords RPC invocation via generic methods on client-side.</p>
  666. <p>Channel objects implement the Context Manager type, although they need not
  667. support being entered and exited multiple times.</p>
  668. <dl class="method">
  669. <dt id="grpc.Channel.close">
  670. <code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.close" title="Permalink to this definition">¶</a></dt>
  671. <dd><p>Closes this Channel and releases all resources held by it.</p>
  672. <p>Closing the Channel will immediately terminate all RPCs active with the
  673. Channel and it is not valid to invoke new RPCs with the Channel.</p>
  674. <p>This method is idempotent.</p>
  675. </dd></dl>
  676. <dl class="method">
  677. <dt id="grpc.Channel.stream_stream">
  678. <code class="descname">stream_stream</code><span class="sig-paren">(</span><em>method</em>, <em>request_serializer=None</em>, <em>response_deserializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.stream_stream"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.stream_stream" title="Permalink to this definition">¶</a></dt>
  679. <dd><p>Creates a StreamStreamMultiCallable for a stream-stream method.</p>
  680. <table class="docutils field-list" frame="void" rules="none">
  681. <col class="field-name" />
  682. <col class="field-body" />
  683. <tbody valign="top">
  684. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  685. <li><strong>method</strong> – The name of the RPC method.</li>
  686. <li><strong>request_serializer</strong> – Optional behaviour for serializing the request
  687. message. Request goes unserialized in case None is passed.</li>
  688. <li><strong>response_deserializer</strong> – Optional behaviour for deserializing the
  689. response message. Response goes undeserialized in case None
  690. is passed.</li>
  691. </ul>
  692. </td>
  693. </tr>
  694. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A StreamStreamMultiCallable value for the named stream-stream method.</p>
  695. </td>
  696. </tr>
  697. </tbody>
  698. </table>
  699. </dd></dl>
  700. <dl class="method">
  701. <dt id="grpc.Channel.stream_unary">
  702. <code class="descname">stream_unary</code><span class="sig-paren">(</span><em>method</em>, <em>request_serializer=None</em>, <em>response_deserializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.stream_unary"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.stream_unary" title="Permalink to this definition">¶</a></dt>
  703. <dd><p>Creates a StreamUnaryMultiCallable for a stream-unary method.</p>
  704. <table class="docutils field-list" frame="void" rules="none">
  705. <col class="field-name" />
  706. <col class="field-body" />
  707. <tbody valign="top">
  708. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  709. <li><strong>method</strong> – The name of the RPC method.</li>
  710. <li><strong>request_serializer</strong> – Optional behaviour for serializing the request
  711. message. Request goes unserialized in case None is passed.</li>
  712. <li><strong>response_deserializer</strong> – Optional behaviour for deserializing the
  713. response message. Response goes undeserialized in case None is
  714. passed.</li>
  715. </ul>
  716. </td>
  717. </tr>
  718. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A StreamUnaryMultiCallable value for the named stream-unary method.</p>
  719. </td>
  720. </tr>
  721. </tbody>
  722. </table>
  723. </dd></dl>
  724. <dl class="method">
  725. <dt id="grpc.Channel.subscribe">
  726. <code class="descname">subscribe</code><span class="sig-paren">(</span><em>callback</em>, <em>try_to_connect=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.subscribe"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.subscribe" title="Permalink to this definition">¶</a></dt>
  727. <dd><p>Subscribe to this Channel’s connectivity state machine.</p>
  728. <p>A Channel may be in any of the states described by ChannelConnectivity.
  729. This method allows application to monitor the state transitions.
  730. The typical use case is to debug or gain better visibility into gRPC
  731. runtime’s state.</p>
  732. <table class="docutils field-list" frame="void" rules="none">
  733. <col class="field-name" />
  734. <col class="field-body" />
  735. <tbody valign="top">
  736. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  737. <li><strong>callback</strong> – A callable to be invoked with ChannelConnectivity argument.
  738. ChannelConnectivity describes current state of the channel.
  739. The callable will be invoked immediately upon subscription
  740. and again for every change to ChannelConnectivity until it
  741. is unsubscribed or this Channel object goes out of scope.</li>
  742. <li><strong>try_to_connect</strong> – A boolean indicating whether or not this Channel
  743. should attempt to connect immediately. If set to False, gRPC
  744. runtime decides when to connect.</li>
  745. </ul>
  746. </td>
  747. </tr>
  748. </tbody>
  749. </table>
  750. </dd></dl>
  751. <dl class="method">
  752. <dt id="grpc.Channel.unary_stream">
  753. <code class="descname">unary_stream</code><span class="sig-paren">(</span><em>method</em>, <em>request_serializer=None</em>, <em>response_deserializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.unary_stream"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.unary_stream" title="Permalink to this definition">¶</a></dt>
  754. <dd><p>Creates a UnaryStreamMultiCallable for a unary-stream method.</p>
  755. <table class="docutils field-list" frame="void" rules="none">
  756. <col class="field-name" />
  757. <col class="field-body" />
  758. <tbody valign="top">
  759. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  760. <li><strong>method</strong> – The name of the RPC method.</li>
  761. <li><strong>request_serializer</strong> – Optional behaviour for serializing the request
  762. message. Request goes unserialized in case None is passed.</li>
  763. <li><strong>response_deserializer</strong> – Optional behaviour for deserializing the
  764. response message. Response goes undeserialized in case None is
  765. passed.</li>
  766. </ul>
  767. </td>
  768. </tr>
  769. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A UnaryStreamMultiCallable value for the name unary-stream method.</p>
  770. </td>
  771. </tr>
  772. </tbody>
  773. </table>
  774. </dd></dl>
  775. <dl class="method">
  776. <dt id="grpc.Channel.unary_unary">
  777. <code class="descname">unary_unary</code><span class="sig-paren">(</span><em>method</em>, <em>request_serializer=None</em>, <em>response_deserializer=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.unary_unary"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.unary_unary" title="Permalink to this definition">¶</a></dt>
  778. <dd><p>Creates a UnaryUnaryMultiCallable for a unary-unary method.</p>
  779. <table class="docutils field-list" frame="void" rules="none">
  780. <col class="field-name" />
  781. <col class="field-body" />
  782. <tbody valign="top">
  783. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  784. <li><strong>method</strong> – The name of the RPC method.</li>
  785. <li><strong>request_serializer</strong> – Optional behaviour for serializing the request
  786. message. Request goes unserialized in case None is passed.</li>
  787. <li><strong>response_deserializer</strong> – Optional behaviour for deserializing the
  788. response message. Response goes undeserialized in case None
  789. is passed.</li>
  790. </ul>
  791. </td>
  792. </tr>
  793. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">A UnaryUnaryMultiCallable value for the named unary-unary method.</p>
  794. </td>
  795. </tr>
  796. </tbody>
  797. </table>
  798. </dd></dl>
  799. <dl class="method">
  800. <dt id="grpc.Channel.unsubscribe">
  801. <code class="descname">unsubscribe</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Channel.unsubscribe"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Channel.unsubscribe" title="Permalink to this definition">¶</a></dt>
  802. <dd><p>Unsubscribes a subscribed callback from this Channel’s connectivity.</p>
  803. <table class="docutils field-list" frame="void" rules="none">
  804. <col class="field-name" />
  805. <col class="field-body" />
  806. <tbody valign="top">
  807. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  808. <li><strong>callback</strong> – A callable previously registered with this Channel from</li>
  809. <li><strong>been passed to its &quot;subscribe&quot; method.</strong> (<em>having</em>) – </li>
  810. </ul>
  811. </td>
  812. </tr>
  813. </tbody>
  814. </table>
  815. </dd></dl>
  816. </dd></dl>
  817. </div>
  818. <div class="section" id="server-object">
  819. <h2>Server Object<a class="headerlink" href="#server-object" title="Permalink to this headline">¶</a></h2>
  820. <dl class="class">
  821. <dt id="grpc.Server">
  822. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">Server</code><a class="reference internal" href="_modules/grpc.html#Server"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Server" title="Permalink to this definition">¶</a></dt>
  823. <dd><p>Services RPCs.</p>
  824. <dl class="method">
  825. <dt id="grpc.Server.add_generic_rpc_handlers">
  826. <code class="descname">add_generic_rpc_handlers</code><span class="sig-paren">(</span><em>generic_rpc_handlers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Server.add_generic_rpc_handlers"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Server.add_generic_rpc_handlers" title="Permalink to this definition">¶</a></dt>
  827. <dd><p>Registers GenericRpcHandlers with this Server.</p>
  828. <p>This method is only safe to call before the server is started.</p>
  829. <table class="docutils field-list" frame="void" rules="none">
  830. <col class="field-name" />
  831. <col class="field-body" />
  832. <tbody valign="top">
  833. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  834. <li><strong>generic_rpc_handlers</strong> – An iterable of GenericRpcHandlers that will be</li>
  835. <li><strong>to service RPCs.</strong> (<em>used</em>) – </li>
  836. </ul>
  837. </td>
  838. </tr>
  839. </tbody>
  840. </table>
  841. </dd></dl>
  842. <dl class="method">
  843. <dt id="grpc.Server.add_insecure_port">
  844. <code class="descname">add_insecure_port</code><span class="sig-paren">(</span><em>address</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Server.add_insecure_port"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Server.add_insecure_port" title="Permalink to this definition">¶</a></dt>
  845. <dd><p>Opens an insecure port for accepting RPCs.</p>
  846. <p>This method may only be called before starting the server.</p>
  847. <table class="docutils field-list" frame="void" rules="none">
  848. <col class="field-name" />
  849. <col class="field-body" />
  850. <tbody valign="top">
  851. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  852. <li><strong>address</strong> – The address for which to open a port.</li>
  853. <li><strong>the port is 0</strong><strong>, or </strong><strong>not specified in the address</strong><strong>, </strong><strong>then gRPC runtime</strong> (<em>if</em>) – </li>
  854. <li><strong>choose a port.</strong> (<em>will</em>) – </li>
  855. </ul>
  856. </td>
  857. </tr>
  858. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An integer port on which server will accept RPC requests.</p>
  859. </td>
  860. </tr>
  861. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">integer</p>
  862. </td>
  863. </tr>
  864. </tbody>
  865. </table>
  866. </dd></dl>
  867. <dl class="method">
  868. <dt id="grpc.Server.add_secure_port">
  869. <code class="descname">add_secure_port</code><span class="sig-paren">(</span><em>address</em>, <em>server_credentials</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Server.add_secure_port"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Server.add_secure_port" title="Permalink to this definition">¶</a></dt>
  870. <dd><p>Opens a secure port for accepting RPCs.</p>
  871. <p>This method may only be called before starting the server.</p>
  872. <table class="docutils field-list" frame="void" rules="none">
  873. <col class="field-name" />
  874. <col class="field-body" />
  875. <tbody valign="top">
  876. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  877. <li><strong>address</strong> – The address for which to open a port.
  878. if the port is 0, or not specified in the address, then gRPC
  879. runtime will choose a port.</li>
  880. <li><strong>server_credentials</strong> – A ServerCredentials object.</li>
  881. </ul>
  882. </td>
  883. </tr>
  884. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An integer port on which server will accept RPC requests.</p>
  885. </td>
  886. </tr>
  887. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">integer</p>
  888. </td>
  889. </tr>
  890. </tbody>
  891. </table>
  892. </dd></dl>
  893. <dl class="method">
  894. <dt id="grpc.Server.start">
  895. <code class="descname">start</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Server.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Server.start" title="Permalink to this definition">¶</a></dt>
  896. <dd><p>Starts this Server.</p>
  897. <p>This method may only be called once. (i.e. it is not idempotent).</p>
  898. </dd></dl>
  899. <dl class="method">
  900. <dt id="grpc.Server.stop">
  901. <code class="descname">stop</code><span class="sig-paren">(</span><em>grace</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Server.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Server.stop" title="Permalink to this definition">¶</a></dt>
  902. <dd><p>Stops this Server.</p>
  903. <p>This method immediately stop service of new RPCs in all cases.</p>
  904. <p>If a grace period is specified, this method returns immediately
  905. and all RPCs active at the end of the grace period are aborted.
  906. If a grace period is not specified (by passing None for <cite>grace</cite>),
  907. all existing RPCs are aborted immediately and this method
  908. blocks until the last RPC handler terminates.</p>
  909. <p>This method is idempotent and may be called at any time.
  910. Passing a smaller grace value in a subsequent call will have
  911. the effect of stopping the Server sooner (passing None will
  912. have the effect of stopping the server immediately). Passing
  913. a larger grace value in a subsequent call <em>will not</em> have the
  914. effect of stopping the server later (i.e. the most restrictive
  915. grace value is used).</p>
  916. <table class="docutils field-list" frame="void" rules="none">
  917. <col class="field-name" />
  918. <col class="field-body" />
  919. <tbody valign="top">
  920. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>grace</strong> – A duration of time in seconds or None.</td>
  921. </tr>
  922. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A threading.Event that will be set when this Server has completely
  923. stopped, i.e. when running RPCs either complete or are aborted and
  924. all handlers have terminated.</td>
  925. </tr>
  926. </tbody>
  927. </table>
  928. </dd></dl>
  929. </dd></dl>
  930. </div>
  931. <div class="section" id="authentication-authorization-objects">
  932. <h2>Authentication &amp; Authorization Objects<a class="headerlink" href="#authentication-authorization-objects" title="Permalink to this headline">¶</a></h2>
  933. <dl class="class">
  934. <dt id="grpc.ChannelCredentials">
  935. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ChannelCredentials</code><span class="sig-paren">(</span><em>credentials</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ChannelCredentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ChannelCredentials" title="Permalink to this definition">¶</a></dt>
  936. <dd><p>An encapsulation of the data required to create a secure Channel.</p>
  937. <p>This class has no supported interface - it exists to define the type of its
  938. instances and its instances exist to be passed to other functions. For
  939. example, ssl_channel_credentials returns an instance of this class and
  940. secure_channel requires an instance of this class.</p>
  941. </dd></dl>
  942. <dl class="class">
  943. <dt id="grpc.CallCredentials">
  944. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">CallCredentials</code><span class="sig-paren">(</span><em>credentials</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#CallCredentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.CallCredentials" title="Permalink to this definition">¶</a></dt>
  945. <dd><p>An encapsulation of the data required to assert an identity over a call.</p>
  946. <p>A CallCredentials may be composed with ChannelCredentials to always assert
  947. identity for every call over that Channel.</p>
  948. <p>This class has no supported interface - it exists to define the type of its
  949. instances and its instances exist to be passed to other functions.</p>
  950. </dd></dl>
  951. <dl class="class">
  952. <dt id="grpc.AuthMetadataContext">
  953. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">AuthMetadataContext</code><a class="reference internal" href="_modules/grpc.html#AuthMetadataContext"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.AuthMetadataContext" title="Permalink to this definition">¶</a></dt>
  954. <dd><p>Provides information to call credentials metadata plugins.</p>
  955. <dl class="attribute">
  956. <dt id="grpc.AuthMetadataContext.service_url">
  957. <code class="descname">service_url</code><a class="headerlink" href="#grpc.AuthMetadataContext.service_url" title="Permalink to this definition">¶</a></dt>
  958. <dd><p>A string URL of the service being called into.</p>
  959. </dd></dl>
  960. <dl class="attribute">
  961. <dt id="grpc.AuthMetadataContext.method_name">
  962. <code class="descname">method_name</code><a class="headerlink" href="#grpc.AuthMetadataContext.method_name" title="Permalink to this definition">¶</a></dt>
  963. <dd><p>A string of the fully qualified method name being called.</p>
  964. </dd></dl>
  965. </dd></dl>
  966. <dl class="class">
  967. <dt id="grpc.AuthMetadataPluginCallback">
  968. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">AuthMetadataPluginCallback</code><a class="reference internal" href="_modules/grpc.html#AuthMetadataPluginCallback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.AuthMetadataPluginCallback" title="Permalink to this definition">¶</a></dt>
  969. <dd><p>Callback object received by a metadata plugin.</p>
  970. <dl class="method">
  971. <dt id="grpc.AuthMetadataPluginCallback.__call__">
  972. <code class="descname">__call__</code><span class="sig-paren">(</span><em>metadata</em>, <em>error</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#AuthMetadataPluginCallback.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.AuthMetadataPluginCallback.__call__" title="Permalink to this definition">¶</a></dt>
  973. <dd><p>Passes to the gRPC runtime authentication metadata for an RPC.</p>
  974. <table class="docutils field-list" frame="void" rules="none">
  975. <col class="field-name" />
  976. <col class="field-body" />
  977. <tbody valign="top">
  978. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  979. <li><strong>metadata</strong> – The <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> used to construct the CallCredentials.</li>
  980. <li><strong>error</strong> – An Exception to indicate error or None to indicate success.</li>
  981. </ul>
  982. </td>
  983. </tr>
  984. </tbody>
  985. </table>
  986. </dd></dl>
  987. </dd></dl>
  988. <dl class="class">
  989. <dt id="grpc.AuthMetadataPlugin">
  990. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">AuthMetadataPlugin</code><a class="reference internal" href="_modules/grpc.html#AuthMetadataPlugin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.AuthMetadataPlugin" title="Permalink to this definition">¶</a></dt>
  991. <dd><p>A specification for custom authentication.</p>
  992. <dl class="method">
  993. <dt id="grpc.AuthMetadataPlugin.__call__">
  994. <code class="descname">__call__</code><span class="sig-paren">(</span><em>context</em>, <em>callback</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#AuthMetadataPlugin.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.AuthMetadataPlugin.__call__" title="Permalink to this definition">¶</a></dt>
  995. <dd><p>Implements authentication by passing metadata to a callback.</p>
  996. <p>Implementations of this method must not block.</p>
  997. <table class="docutils field-list" frame="void" rules="none">
  998. <col class="field-name" />
  999. <col class="field-body" />
  1000. <tbody valign="top">
  1001. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  1002. <li><strong>context</strong> – An AuthMetadataContext providing information on the RPC that
  1003. the plugin is being called to authenticate.</li>
  1004. <li><strong>callback</strong> – An AuthMetadataPluginCallback to be invoked either
  1005. synchronously or asynchronously.</li>
  1006. </ul>
  1007. </td>
  1008. </tr>
  1009. </tbody>
  1010. </table>
  1011. </dd></dl>
  1012. </dd></dl>
  1013. <dl class="class">
  1014. <dt id="grpc.ServerCredentials">
  1015. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ServerCredentials</code><span class="sig-paren">(</span><em>credentials</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServerCredentials"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServerCredentials" title="Permalink to this definition">¶</a></dt>
  1016. <dd><p>An encapsulation of the data required to open a secure port on a Server.</p>
  1017. <p>This class has no supported interface - it exists to define the type of its
  1018. instances and its instances exist to be passed to other functions.</p>
  1019. </dd></dl>
  1020. <dl class="class">
  1021. <dt id="grpc.ServerCertificateConfiguration">
  1022. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ServerCertificateConfiguration</code><span class="sig-paren">(</span><em>certificate_configuration</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServerCertificateConfiguration"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServerCertificateConfiguration" title="Permalink to this definition">¶</a></dt>
  1023. <dd><p>A certificate configuration for use with an SSL-enabled Server.</p>
  1024. <p>Instances of this class can be returned in the certificate configuration
  1025. fetching callback.</p>
  1026. <p>This class has no supported interface – it exists to define the
  1027. type of its instances and its instances exist to be passed to
  1028. other functions.</p>
  1029. </dd></dl>
  1030. </div>
  1031. <div class="section" id="grpc-exceptions">
  1032. <h2>gRPC Exceptions<a class="headerlink" href="#grpc-exceptions" title="Permalink to this headline">¶</a></h2>
  1033. <dl class="exception">
  1034. <dt id="grpc.RpcError">
  1035. <em class="property">exception </em><code class="descclassname">grpc.</code><code class="descname">RpcError</code><a class="reference internal" href="_modules/grpc.html#RpcError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcError" title="Permalink to this definition">¶</a></dt>
  1036. <dd><p>Raised by the gRPC library to indicate non-OK-status RPC termination.</p>
  1037. </dd></dl>
  1038. </div>
  1039. <div class="section" id="shared-context">
  1040. <h2>Shared Context<a class="headerlink" href="#shared-context" title="Permalink to this headline">¶</a></h2>
  1041. <dl class="class">
  1042. <dt id="grpc.RpcContext">
  1043. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">RpcContext</code><a class="reference internal" href="_modules/grpc.html#RpcContext"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcContext" title="Permalink to this definition">¶</a></dt>
  1044. <dd><p>Provides RPC-related information and action.</p>
  1045. <dl class="method">
  1046. <dt id="grpc.RpcContext.add_callback">
  1047. <code class="descname">add_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#RpcContext.add_callback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcContext.add_callback" title="Permalink to this definition">¶</a></dt>
  1048. <dd><p>Registers a callback to be called on RPC termination.</p>
  1049. <table class="docutils field-list" frame="void" rules="none">
  1050. <col class="field-name" />
  1051. <col class="field-body" />
  1052. <tbody valign="top">
  1053. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – A no-parameter callable to be called on RPC termination.</td>
  1054. </tr>
  1055. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">True if the callback was added and will be called later; False if
  1056. the callback was not added and will not be called (because the RPC
  1057. already terminated or some other reason).</td>
  1058. </tr>
  1059. <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  1060. </tr>
  1061. </tbody>
  1062. </table>
  1063. </dd></dl>
  1064. <dl class="method">
  1065. <dt id="grpc.RpcContext.cancel">
  1066. <code class="descname">cancel</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#RpcContext.cancel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcContext.cancel" title="Permalink to this definition">¶</a></dt>
  1067. <dd><p>Cancels the RPC.</p>
  1068. <p>Idempotent and has no effect if the RPC has already terminated.</p>
  1069. </dd></dl>
  1070. <dl class="method">
  1071. <dt id="grpc.RpcContext.is_active">
  1072. <code class="descname">is_active</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#RpcContext.is_active"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcContext.is_active" title="Permalink to this definition">¶</a></dt>
  1073. <dd><p>Describes whether the RPC is active or has terminated.</p>
  1074. <table class="docutils field-list" frame="void" rules="none">
  1075. <col class="field-name" />
  1076. <col class="field-body" />
  1077. <tbody valign="top">
  1078. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True if RPC is active, False otherwise.</td>
  1079. </tr>
  1080. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  1081. </tr>
  1082. </tbody>
  1083. </table>
  1084. </dd></dl>
  1085. <dl class="method">
  1086. <dt id="grpc.RpcContext.time_remaining">
  1087. <code class="descname">time_remaining</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#RpcContext.time_remaining"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcContext.time_remaining" title="Permalink to this definition">¶</a></dt>
  1088. <dd><p>Describes the length of allowed time remaining for the RPC.</p>
  1089. <table class="docutils field-list" frame="void" rules="none">
  1090. <col class="field-name" />
  1091. <col class="field-body" />
  1092. <tbody valign="top">
  1093. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A nonnegative float indicating the length of allowed time in seconds
  1094. remaining for the RPC to complete before it is considered to have
  1095. timed out, or None if no deadline was specified for the RPC.</td>
  1096. </tr>
  1097. </tbody>
  1098. </table>
  1099. </dd></dl>
  1100. </dd></dl>
  1101. </div>
  1102. <div class="section" id="client-side-context">
  1103. <h2>Client-Side Context<a class="headerlink" href="#client-side-context" title="Permalink to this headline">¶</a></h2>
  1104. <dl class="class">
  1105. <dt id="grpc.Call">
  1106. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">Call</code><a class="reference internal" href="_modules/grpc.html#Call"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Call" title="Permalink to this definition">¶</a></dt>
  1107. <dd><p>Invocation-side utility object for an RPC.</p>
  1108. <dl class="method">
  1109. <dt id="grpc.Call.code">
  1110. <code class="descname">code</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Call.code"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Call.code" title="Permalink to this definition">¶</a></dt>
  1111. <dd><p>Accesses the status code sent by the server.</p>
  1112. <p>This method blocks until the value is available.</p>
  1113. <table class="docutils field-list" frame="void" rules="none">
  1114. <col class="field-name" />
  1115. <col class="field-body" />
  1116. <tbody valign="top">
  1117. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The StatusCode value for the RPC.</td>
  1118. </tr>
  1119. </tbody>
  1120. </table>
  1121. </dd></dl>
  1122. <dl class="method">
  1123. <dt id="grpc.Call.details">
  1124. <code class="descname">details</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Call.details"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Call.details" title="Permalink to this definition">¶</a></dt>
  1125. <dd><p>Accesses the details sent by the server.</p>
  1126. <p>This method blocks until the value is available.</p>
  1127. <table class="docutils field-list" frame="void" rules="none">
  1128. <col class="field-name" />
  1129. <col class="field-body" />
  1130. <tbody valign="top">
  1131. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The details string of the RPC.</td>
  1132. </tr>
  1133. </tbody>
  1134. </table>
  1135. </dd></dl>
  1136. <dl class="method">
  1137. <dt id="grpc.Call.initial_metadata">
  1138. <code class="descname">initial_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Call.initial_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Call.initial_metadata" title="Permalink to this definition">¶</a></dt>
  1139. <dd><p>Accesses the initial metadata sent by the server.</p>
  1140. <p>This method blocks until the value is available.</p>
  1141. <table class="docutils field-list" frame="void" rules="none">
  1142. <col class="field-name" />
  1143. <col class="field-body" />
  1144. <tbody valign="top">
  1145. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The initial <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a>.</td>
  1146. </tr>
  1147. </tbody>
  1148. </table>
  1149. </dd></dl>
  1150. <dl class="method">
  1151. <dt id="grpc.Call.trailing_metadata">
  1152. <code class="descname">trailing_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Call.trailing_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Call.trailing_metadata" title="Permalink to this definition">¶</a></dt>
  1153. <dd><p>Accesses the trailing metadata sent by the server.</p>
  1154. <p>This method blocks until the value is available.</p>
  1155. <table class="docutils field-list" frame="void" rules="none">
  1156. <col class="field-name" />
  1157. <col class="field-body" />
  1158. <tbody valign="top">
  1159. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The trailing <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a>.</td>
  1160. </tr>
  1161. </tbody>
  1162. </table>
  1163. </dd></dl>
  1164. </dd></dl>
  1165. </div>
  1166. <div class="section" id="client-side-interceptor">
  1167. <h2>Client-Side Interceptor<a class="headerlink" href="#client-side-interceptor" title="Permalink to this headline">¶</a></h2>
  1168. <dl class="class">
  1169. <dt id="grpc.ClientCallDetails">
  1170. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ClientCallDetails</code><a class="reference internal" href="_modules/grpc.html#ClientCallDetails"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ClientCallDetails" title="Permalink to this definition">¶</a></dt>
  1171. <dd><p>Describes an RPC to be invoked.</p>
  1172. <p>This is an EXPERIMENTAL API.</p>
  1173. <dl class="attribute">
  1174. <dt id="grpc.ClientCallDetails.method">
  1175. <code class="descname">method</code><a class="headerlink" href="#grpc.ClientCallDetails.method" title="Permalink to this definition">¶</a></dt>
  1176. <dd><p>The method name of the RPC.</p>
  1177. </dd></dl>
  1178. <dl class="attribute">
  1179. <dt id="grpc.ClientCallDetails.timeout">
  1180. <code class="descname">timeout</code><a class="headerlink" href="#grpc.ClientCallDetails.timeout" title="Permalink to this definition">¶</a></dt>
  1181. <dd><p>An optional duration of time in seconds to allow for the RPC.</p>
  1182. </dd></dl>
  1183. <dl class="attribute">
  1184. <dt id="grpc.ClientCallDetails.metadata">
  1185. <code class="descname">metadata</code><a class="headerlink" href="#grpc.ClientCallDetails.metadata" title="Permalink to this definition">¶</a></dt>
  1186. <dd><p>Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to
  1187. the service-side of the RPC.</p>
  1188. </dd></dl>
  1189. <dl class="attribute">
  1190. <dt id="grpc.ClientCallDetails.credentials">
  1191. <code class="descname">credentials</code><a class="headerlink" href="#grpc.ClientCallDetails.credentials" title="Permalink to this definition">¶</a></dt>
  1192. <dd><p>An optional CallCredentials for the RPC.</p>
  1193. </dd></dl>
  1194. <dl class="attribute">
  1195. <dt id="grpc.ClientCallDetails.wait_for_ready">
  1196. <code class="descname">wait_for_ready</code><a class="headerlink" href="#grpc.ClientCallDetails.wait_for_ready" title="Permalink to this definition">¶</a></dt>
  1197. <dd><p>An optional flag to enable wait for ready mechanism.</p>
  1198. </dd></dl>
  1199. </dd></dl>
  1200. <dl class="class">
  1201. <dt id="grpc.UnaryUnaryClientInterceptor">
  1202. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">UnaryUnaryClientInterceptor</code><a class="reference internal" href="_modules/grpc.html#UnaryUnaryClientInterceptor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryUnaryClientInterceptor" title="Permalink to this definition">¶</a></dt>
  1203. <dd><p>Affords intercepting unary-unary invocations.</p>
  1204. <p>This is an EXPERIMENTAL API.</p>
  1205. <dl class="method">
  1206. <dt id="grpc.UnaryUnaryClientInterceptor.intercept_unary_unary">
  1207. <code class="descname">intercept_unary_unary</code><span class="sig-paren">(</span><em>continuation</em>, <em>client_call_details</em>, <em>request</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#UnaryUnaryClientInterceptor.intercept_unary_unary"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryUnaryClientInterceptor.intercept_unary_unary" title="Permalink to this definition">¶</a></dt>
  1208. <dd><p>Intercepts a unary-unary invocation asynchronously.</p>
  1209. <table class="docutils field-list" frame="void" rules="none">
  1210. <col class="field-name" />
  1211. <col class="field-body" />
  1212. <tbody valign="top">
  1213. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1214. <li><strong>continuation</strong> – A function that proceeds with the invocation by
  1215. executing the next interceptor in chain or invoking the
  1216. actual RPC on the underlying Channel. It is the interceptor’s
  1217. responsibility to call it if it decides to move the RPC forward.
  1218. The interceptor can use
  1219. <cite>response_future = continuation(client_call_details, request)</cite>
  1220. to continue with the RPC. <cite>continuation</cite> returns an object that is
  1221. both a Call for the RPC and a Future. In the event of RPC
  1222. completion, the return Call-Future’s result value will be
  1223. the response message of the RPC. Should the event terminate
  1224. with non-OK status, the returned Call-Future’s exception value
  1225. will be an RpcError.</li>
  1226. <li><strong>client_call_details</strong> – A ClientCallDetails object describing the
  1227. outgoing RPC.</li>
  1228. <li><strong>request</strong> – The request value for the RPC.</li>
  1229. </ul>
  1230. </td>
  1231. </tr>
  1232. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and a Future.
  1233. In the event of RPC completion, the return Call-Future’s
  1234. result value will be the response message of the RPC.
  1235. Should the event terminate with non-OK status, the returned
  1236. Call-Future’s exception value will be an RpcError.</p>
  1237. </td>
  1238. </tr>
  1239. </tbody>
  1240. </table>
  1241. </dd></dl>
  1242. </dd></dl>
  1243. <dl class="class">
  1244. <dt id="grpc.UnaryStreamClientInterceptor">
  1245. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">UnaryStreamClientInterceptor</code><a class="reference internal" href="_modules/grpc.html#UnaryStreamClientInterceptor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryStreamClientInterceptor" title="Permalink to this definition">¶</a></dt>
  1246. <dd><p>Affords intercepting unary-stream invocations.</p>
  1247. <p>This is an EXPERIMENTAL API.</p>
  1248. <dl class="method">
  1249. <dt id="grpc.UnaryStreamClientInterceptor.intercept_unary_stream">
  1250. <code class="descname">intercept_unary_stream</code><span class="sig-paren">(</span><em>continuation</em>, <em>client_call_details</em>, <em>request</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#UnaryStreamClientInterceptor.intercept_unary_stream"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryStreamClientInterceptor.intercept_unary_stream" title="Permalink to this definition">¶</a></dt>
  1251. <dd><p>Intercepts a unary-stream invocation.</p>
  1252. <table class="docutils field-list" frame="void" rules="none">
  1253. <col class="field-name" />
  1254. <col class="field-body" />
  1255. <tbody valign="top">
  1256. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1257. <li><strong>continuation</strong> – A function that proceeds with the invocation by
  1258. executing the next interceptor in chain or invoking the
  1259. actual RPC on the underlying Channel. It is the interceptor’s
  1260. responsibility to call it if it decides to move the RPC forward.
  1261. The interceptor can use
  1262. <cite>response_iterator = continuation(client_call_details, request)</cite>
  1263. to continue with the RPC. <cite>continuation</cite> returns an object that is
  1264. both a Call for the RPC and an iterator for response values.
  1265. Drawing response values from the returned Call-iterator may
  1266. raise RpcError indicating termination of the RPC with non-OK
  1267. status.</li>
  1268. <li><strong>client_call_details</strong> – A ClientCallDetails object describing the
  1269. outgoing RPC.</li>
  1270. <li><strong>request</strong> – The request value for the RPC.</li>
  1271. </ul>
  1272. </td>
  1273. </tr>
  1274. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and an iterator of
  1275. response values. Drawing response values from the returned
  1276. Call-iterator may raise RpcError indicating termination of
  1277. the RPC with non-OK status.</p>
  1278. </td>
  1279. </tr>
  1280. </tbody>
  1281. </table>
  1282. </dd></dl>
  1283. </dd></dl>
  1284. <dl class="class">
  1285. <dt id="grpc.StreamUnaryClientInterceptor">
  1286. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">StreamUnaryClientInterceptor</code><a class="reference internal" href="_modules/grpc.html#StreamUnaryClientInterceptor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamUnaryClientInterceptor" title="Permalink to this definition">¶</a></dt>
  1287. <dd><p>Affords intercepting stream-unary invocations.</p>
  1288. <p>This is an EXPERIMENTAL API.</p>
  1289. <dl class="method">
  1290. <dt id="grpc.StreamUnaryClientInterceptor.intercept_stream_unary">
  1291. <code class="descname">intercept_stream_unary</code><span class="sig-paren">(</span><em>continuation</em>, <em>client_call_details</em>, <em>request_iterator</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#StreamUnaryClientInterceptor.intercept_stream_unary"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamUnaryClientInterceptor.intercept_stream_unary" title="Permalink to this definition">¶</a></dt>
  1292. <dd><p>Intercepts a stream-unary invocation asynchronously.</p>
  1293. <table class="docutils field-list" frame="void" rules="none">
  1294. <col class="field-name" />
  1295. <col class="field-body" />
  1296. <tbody valign="top">
  1297. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1298. <li><strong>continuation</strong> – A function that proceeds with the invocation by
  1299. executing the next interceptor in chain or invoking the
  1300. actual RPC on the underlying Channel. It is the interceptor’s
  1301. responsibility to call it if it decides to move the RPC forward.
  1302. The interceptor can use
  1303. <cite>response_future = continuation(client_call_details, request_iterator)</cite>
  1304. to continue with the RPC. <cite>continuation</cite> returns an object that is
  1305. both a Call for the RPC and a Future. In the event of RPC completion,
  1306. the return Call-Future’s result value will be the response message
  1307. of the RPC. Should the event terminate with non-OK status, the
  1308. returned Call-Future’s exception value will be an RpcError.</li>
  1309. <li><strong>client_call_details</strong> – A ClientCallDetails object describing the
  1310. outgoing RPC.</li>
  1311. <li><strong>request_iterator</strong> – An iterator that yields request values for the RPC.</li>
  1312. </ul>
  1313. </td>
  1314. </tr>
  1315. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and a Future.
  1316. In the event of RPC completion, the return Call-Future’s
  1317. result value will be the response message of the RPC.
  1318. Should the event terminate with non-OK status, the returned
  1319. Call-Future’s exception value will be an RpcError.</p>
  1320. </td>
  1321. </tr>
  1322. </tbody>
  1323. </table>
  1324. </dd></dl>
  1325. </dd></dl>
  1326. <dl class="class">
  1327. <dt id="grpc.StreamStreamClientInterceptor">
  1328. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">StreamStreamClientInterceptor</code><a class="reference internal" href="_modules/grpc.html#StreamStreamClientInterceptor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamStreamClientInterceptor" title="Permalink to this definition">¶</a></dt>
  1329. <dd><p>Affords intercepting stream-stream invocations.</p>
  1330. <p>This is an EXPERIMENTAL API.</p>
  1331. <dl class="method">
  1332. <dt id="grpc.StreamStreamClientInterceptor.intercept_stream_stream">
  1333. <code class="descname">intercept_stream_stream</code><span class="sig-paren">(</span><em>continuation</em>, <em>client_call_details</em>, <em>request_iterator</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#StreamStreamClientInterceptor.intercept_stream_stream"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamStreamClientInterceptor.intercept_stream_stream" title="Permalink to this definition">¶</a></dt>
  1334. <dd><p>Intercepts a stream-stream invocation.</p>
  1335. <table class="docutils field-list" frame="void" rules="none">
  1336. <col class="field-name" />
  1337. <col class="field-body" />
  1338. <tbody valign="top">
  1339. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1340. <li><strong>continuation</strong> – A function that proceeds with the invocation by
  1341. executing the next interceptor in chain or invoking the
  1342. actual RPC on the underlying Channel. It is the interceptor’s
  1343. responsibility to call it if it decides to move the RPC forward.
  1344. The interceptor can use
  1345. <cite>response_iterator = continuation(client_call_details, request_iterator)</cite>
  1346. to continue with the RPC. <cite>continuation</cite> returns an object that is
  1347. both a Call for the RPC and an iterator for response values.
  1348. Drawing response values from the returned Call-iterator may
  1349. raise RpcError indicating termination of the RPC with non-OK
  1350. status.</li>
  1351. <li><strong>client_call_details</strong> – A ClientCallDetails object describing the
  1352. outgoing RPC.</li>
  1353. <li><strong>request_iterator</strong> – An iterator that yields request values for the RPC.</li>
  1354. </ul>
  1355. </td>
  1356. </tr>
  1357. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and an iterator of
  1358. response values. Drawing response values from the returned
  1359. Call-iterator may raise RpcError indicating termination of
  1360. the RPC with non-OK status.</p>
  1361. </td>
  1362. </tr>
  1363. </tbody>
  1364. </table>
  1365. </dd></dl>
  1366. </dd></dl>
  1367. </div>
  1368. <div class="section" id="service-side-context">
  1369. <h2>Service-Side Context<a class="headerlink" href="#service-side-context" title="Permalink to this headline">¶</a></h2>
  1370. <dl class="class">
  1371. <dt id="grpc.ServicerContext">
  1372. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ServicerContext</code><a class="reference internal" href="_modules/grpc.html#ServicerContext"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext" title="Permalink to this definition">¶</a></dt>
  1373. <dd><p>A context object passed to method implementations.</p>
  1374. <dl class="method">
  1375. <dt id="grpc.ServicerContext.abort">
  1376. <code class="descname">abort</code><span class="sig-paren">(</span><em>code</em>, <em>details</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.abort"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.abort" title="Permalink to this definition">¶</a></dt>
  1377. <dd><p>Raises an exception to terminate the RPC with a non-OK status.</p>
  1378. <p>The code and details passed as arguments will supercede any existing
  1379. ones.</p>
  1380. <table class="docutils field-list" frame="void" rules="none">
  1381. <col class="field-name" />
  1382. <col class="field-body" />
  1383. <tbody valign="top">
  1384. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1385. <li><strong>code</strong> – A StatusCode object to be sent to the client.
  1386. It must not be StatusCode.OK.</li>
  1387. <li><strong>details</strong> – An ASCII-encodable string to be sent to the client upon
  1388. termination of the RPC.</li>
  1389. </ul>
  1390. </td>
  1391. </tr>
  1392. <tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code> – An exception is always raised to signal the abortion the
  1393. RPC to the gRPC runtime.</p>
  1394. </td>
  1395. </tr>
  1396. </tbody>
  1397. </table>
  1398. </dd></dl>
  1399. <dl class="method">
  1400. <dt id="grpc.ServicerContext.auth_context">
  1401. <code class="descname">auth_context</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.auth_context"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.auth_context" title="Permalink to this definition">¶</a></dt>
  1402. <dd><p>Gets the auth context for the call.</p>
  1403. <table class="docutils field-list" frame="void" rules="none">
  1404. <col class="field-name" />
  1405. <col class="field-body" />
  1406. <tbody valign="top">
  1407. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A map of strings to an iterable of bytes for each auth property.</td>
  1408. </tr>
  1409. </tbody>
  1410. </table>
  1411. </dd></dl>
  1412. <dl class="method">
  1413. <dt id="grpc.ServicerContext.invocation_metadata">
  1414. <code class="descname">invocation_metadata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.invocation_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.invocation_metadata" title="Permalink to this definition">¶</a></dt>
  1415. <dd><p>Accesses the metadata from the sent by the client.</p>
  1416. <table class="docutils field-list" frame="void" rules="none">
  1417. <col class="field-name" />
  1418. <col class="field-body" />
  1419. <tbody valign="top">
  1420. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The invocation <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a>.</td>
  1421. </tr>
  1422. </tbody>
  1423. </table>
  1424. </dd></dl>
  1425. <dl class="method">
  1426. <dt id="grpc.ServicerContext.peer">
  1427. <code class="descname">peer</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.peer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.peer" title="Permalink to this definition">¶</a></dt>
  1428. <dd><p>Identifies the peer that invoked the RPC being serviced.</p>
  1429. <table class="docutils field-list" frame="void" rules="none">
  1430. <col class="field-name" />
  1431. <col class="field-body" />
  1432. <tbody valign="top">
  1433. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A string identifying the peer that invoked the RPC being serviced.
  1434. The string format is determined by gRPC runtime.</td>
  1435. </tr>
  1436. </tbody>
  1437. </table>
  1438. </dd></dl>
  1439. <dl class="method">
  1440. <dt id="grpc.ServicerContext.peer_identities">
  1441. <code class="descname">peer_identities</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.peer_identities"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.peer_identities" title="Permalink to this definition">¶</a></dt>
  1442. <dd><p>Gets one or more peer identity(s).</p>
  1443. <p>Equivalent to
  1444. servicer_context.auth_context().get(servicer_context.peer_identity_key())</p>
  1445. <table class="docutils field-list" frame="void" rules="none">
  1446. <col class="field-name" />
  1447. <col class="field-body" />
  1448. <tbody valign="top">
  1449. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An iterable of the identities, or None if the call is not
  1450. authenticated. Each identity is returned as a raw bytes type.</td>
  1451. </tr>
  1452. </tbody>
  1453. </table>
  1454. </dd></dl>
  1455. <dl class="method">
  1456. <dt id="grpc.ServicerContext.peer_identity_key">
  1457. <code class="descname">peer_identity_key</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.peer_identity_key"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.peer_identity_key" title="Permalink to this definition">¶</a></dt>
  1458. <dd><p>The auth property used to identify the peer.</p>
  1459. <p>For example, “x509_common_name” or “x509_subject_alternative_name” are
  1460. used to identify an SSL peer.</p>
  1461. <table class="docutils field-list" frame="void" rules="none">
  1462. <col class="field-name" />
  1463. <col class="field-body" />
  1464. <tbody valign="top">
  1465. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The auth property (string) that indicates the
  1466. peer identity, or None if the call is not authenticated.</td>
  1467. </tr>
  1468. </tbody>
  1469. </table>
  1470. </dd></dl>
  1471. <dl class="method">
  1472. <dt id="grpc.ServicerContext.send_initial_metadata">
  1473. <code class="descname">send_initial_metadata</code><span class="sig-paren">(</span><em>initial_metadata</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.send_initial_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.send_initial_metadata" title="Permalink to this definition">¶</a></dt>
  1474. <dd><p>Sends the initial metadata value to the client.</p>
  1475. <p>This method need not be called by implementations if they have no
  1476. metadata to add to what the gRPC runtime will transmit.</p>
  1477. <table class="docutils field-list" frame="void" rules="none">
  1478. <col class="field-name" />
  1479. <col class="field-body" />
  1480. <tbody valign="top">
  1481. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>initial_metadata</strong> – The initial <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a>.</td>
  1482. </tr>
  1483. </tbody>
  1484. </table>
  1485. </dd></dl>
  1486. <dl class="method">
  1487. <dt id="grpc.ServicerContext.set_code">
  1488. <code class="descname">set_code</code><span class="sig-paren">(</span><em>code</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.set_code"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.set_code" title="Permalink to this definition">¶</a></dt>
  1489. <dd><p>Sets the value to be used as status code upon RPC completion.</p>
  1490. <p>This method need not be called by method implementations if they wish
  1491. the gRPC runtime to determine the status code of the RPC.</p>
  1492. <table class="docutils field-list" frame="void" rules="none">
  1493. <col class="field-name" />
  1494. <col class="field-body" />
  1495. <tbody valign="top">
  1496. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>code</strong> – A StatusCode object to be sent to the client.</td>
  1497. </tr>
  1498. </tbody>
  1499. </table>
  1500. </dd></dl>
  1501. <dl class="method">
  1502. <dt id="grpc.ServicerContext.set_details">
  1503. <code class="descname">set_details</code><span class="sig-paren">(</span><em>details</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.set_details"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.set_details" title="Permalink to this definition">¶</a></dt>
  1504. <dd><p>Sets the value to be used as detail string upon RPC completion.</p>
  1505. <p>This method need not be called by method implementations if they have
  1506. no details to transmit.</p>
  1507. <table class="docutils field-list" frame="void" rules="none">
  1508. <col class="field-name" />
  1509. <col class="field-body" />
  1510. <tbody valign="top">
  1511. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>details</strong> – An ASCII-encodable string to be sent to the client upon
  1512. termination of the RPC.</td>
  1513. </tr>
  1514. </tbody>
  1515. </table>
  1516. </dd></dl>
  1517. <dl class="method">
  1518. <dt id="grpc.ServicerContext.set_trailing_metadata">
  1519. <code class="descname">set_trailing_metadata</code><span class="sig-paren">(</span><em>trailing_metadata</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServicerContext.set_trailing_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServicerContext.set_trailing_metadata" title="Permalink to this definition">¶</a></dt>
  1520. <dd><p>Sends the trailing metadata for the RPC.</p>
  1521. <p>This method need not be called by implementations if they have no
  1522. metadata to add to what the gRPC runtime will transmit.</p>
  1523. <table class="docutils field-list" frame="void" rules="none">
  1524. <col class="field-name" />
  1525. <col class="field-body" />
  1526. <tbody valign="top">
  1527. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>trailing_metadata</strong> – The trailing <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a>.</td>
  1528. </tr>
  1529. </tbody>
  1530. </table>
  1531. </dd></dl>
  1532. </dd></dl>
  1533. </div>
  1534. <div class="section" id="service-side-handler">
  1535. <h2>Service-Side Handler<a class="headerlink" href="#service-side-handler" title="Permalink to this headline">¶</a></h2>
  1536. <dl class="class">
  1537. <dt id="grpc.RpcMethodHandler">
  1538. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">RpcMethodHandler</code><a class="reference internal" href="_modules/grpc.html#RpcMethodHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.RpcMethodHandler" title="Permalink to this definition">¶</a></dt>
  1539. <dd><p>An implementation of a single RPC method.</p>
  1540. <dl class="attribute">
  1541. <dt id="grpc.RpcMethodHandler.request_streaming">
  1542. <code class="descname">request_streaming</code><a class="headerlink" href="#grpc.RpcMethodHandler.request_streaming" title="Permalink to this definition">¶</a></dt>
  1543. <dd><p>Whether the RPC supports exactly one request message
  1544. or any arbitrary number of request messages.</p>
  1545. </dd></dl>
  1546. <dl class="attribute">
  1547. <dt id="grpc.RpcMethodHandler.response_streaming">
  1548. <code class="descname">response_streaming</code><a class="headerlink" href="#grpc.RpcMethodHandler.response_streaming" title="Permalink to this definition">¶</a></dt>
  1549. <dd><p>Whether the RPC supports exactly one response message
  1550. or any arbitrary number of response messages.</p>
  1551. </dd></dl>
  1552. <dl class="attribute">
  1553. <dt id="grpc.RpcMethodHandler.request_deserializer">
  1554. <code class="descname">request_deserializer</code><a class="headerlink" href="#grpc.RpcMethodHandler.request_deserializer" title="Permalink to this definition">¶</a></dt>
  1555. <dd><p>A callable behavior that accepts a byte string and
  1556. returns an object suitable to be passed to this object’s business
  1557. logic, or None to indicate that this object’s business logic should be
  1558. passed the raw request bytes.</p>
  1559. </dd></dl>
  1560. <dl class="attribute">
  1561. <dt id="grpc.RpcMethodHandler.response_serializer">
  1562. <code class="descname">response_serializer</code><a class="headerlink" href="#grpc.RpcMethodHandler.response_serializer" title="Permalink to this definition">¶</a></dt>
  1563. <dd><p>A callable behavior that accepts an object produced
  1564. by this object’s business logic and returns a byte string, or None to
  1565. indicate that the byte strings produced by this object’s business logic
  1566. should be transmitted on the wire as they are.</p>
  1567. </dd></dl>
  1568. <dl class="attribute">
  1569. <dt id="grpc.RpcMethodHandler.unary_unary">
  1570. <code class="descname">unary_unary</code><a class="headerlink" href="#grpc.RpcMethodHandler.unary_unary" title="Permalink to this definition">¶</a></dt>
  1571. <dd><p>This object’s application-specific business logic as a
  1572. callable value that takes a request value and a ServicerContext object
  1573. and returns a response value. Only non-None if both request_streaming
  1574. and response_streaming are False.</p>
  1575. </dd></dl>
  1576. <dl class="attribute">
  1577. <dt id="grpc.RpcMethodHandler.unary_stream">
  1578. <code class="descname">unary_stream</code><a class="headerlink" href="#grpc.RpcMethodHandler.unary_stream" title="Permalink to this definition">¶</a></dt>
  1579. <dd><p>This object’s application-specific business logic as a
  1580. callable value that takes a request value and a ServicerContext object
  1581. and returns an iterator of response values. Only non-None if
  1582. request_streaming is False and response_streaming is True.</p>
  1583. </dd></dl>
  1584. <dl class="attribute">
  1585. <dt id="grpc.RpcMethodHandler.stream_unary">
  1586. <code class="descname">stream_unary</code><a class="headerlink" href="#grpc.RpcMethodHandler.stream_unary" title="Permalink to this definition">¶</a></dt>
  1587. <dd><p>This object’s application-specific business logic as a
  1588. callable value that takes an iterator of request values and a
  1589. ServicerContext object and returns a response value. Only non-None if
  1590. request_streaming is True and response_streaming is False.</p>
  1591. </dd></dl>
  1592. <dl class="attribute">
  1593. <dt id="grpc.RpcMethodHandler.stream_stream">
  1594. <code class="descname">stream_stream</code><a class="headerlink" href="#grpc.RpcMethodHandler.stream_stream" title="Permalink to this definition">¶</a></dt>
  1595. <dd><p>This object’s application-specific business logic as a
  1596. callable value that takes an iterator of request values and a
  1597. ServicerContext object and returns an iterator of response values.
  1598. Only non-None if request_streaming and response_streaming are both
  1599. True.</p>
  1600. </dd></dl>
  1601. </dd></dl>
  1602. <dl class="class">
  1603. <dt id="grpc.HandlerCallDetails">
  1604. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">HandlerCallDetails</code><a class="reference internal" href="_modules/grpc.html#HandlerCallDetails"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.HandlerCallDetails" title="Permalink to this definition">¶</a></dt>
  1605. <dd><p>Describes an RPC that has just arrived for service.
  1606. .. attribute:: method</p>
  1607. <blockquote>
  1608. <div>The method name of the RPC.</div></blockquote>
  1609. <dl class="attribute">
  1610. <dt id="grpc.HandlerCallDetails.invocation_metadata">
  1611. <code class="descname">invocation_metadata</code><a class="headerlink" href="#grpc.HandlerCallDetails.invocation_metadata" title="Permalink to this definition">¶</a></dt>
  1612. <dd><p>The <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> sent by the client.</p>
  1613. </dd></dl>
  1614. </dd></dl>
  1615. <dl class="class">
  1616. <dt id="grpc.GenericRpcHandler">
  1617. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">GenericRpcHandler</code><a class="reference internal" href="_modules/grpc.html#GenericRpcHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.GenericRpcHandler" title="Permalink to this definition">¶</a></dt>
  1618. <dd><p>An implementation of arbitrarily many RPC methods.</p>
  1619. <dl class="method">
  1620. <dt id="grpc.GenericRpcHandler.service">
  1621. <code class="descname">service</code><span class="sig-paren">(</span><em>handler_call_details</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#GenericRpcHandler.service"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.GenericRpcHandler.service" title="Permalink to this definition">¶</a></dt>
  1622. <dd><p>Returns the handler for servicing the RPC.</p>
  1623. <table class="docutils field-list" frame="void" rules="none">
  1624. <col class="field-name" />
  1625. <col class="field-body" />
  1626. <tbody valign="top">
  1627. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>handler_call_details</strong> – A HandlerCallDetails describing the RPC.</td>
  1628. </tr>
  1629. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">An RpcMethodHandler with which the RPC may be serviced if the
  1630. implementation chooses to service this RPC, or None otherwise.</td>
  1631. </tr>
  1632. </tbody>
  1633. </table>
  1634. </dd></dl>
  1635. </dd></dl>
  1636. <dl class="class">
  1637. <dt id="grpc.ServiceRpcHandler">
  1638. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ServiceRpcHandler</code><a class="reference internal" href="_modules/grpc.html#ServiceRpcHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServiceRpcHandler" title="Permalink to this definition">¶</a></dt>
  1639. <dd><p>An implementation of RPC methods belonging to a service.</p>
  1640. <p>A service handles RPC methods with structured names of the form
  1641. ‘/Service.Name/Service.Method’, where ‘Service.Name’ is the value
  1642. returned by service_name(), and ‘Service.Method’ is the method
  1643. name. A service can have multiple method names, but only a single
  1644. service name.</p>
  1645. <dl class="method">
  1646. <dt id="grpc.ServiceRpcHandler.service_name">
  1647. <code class="descname">service_name</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServiceRpcHandler.service_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServiceRpcHandler.service_name" title="Permalink to this definition">¶</a></dt>
  1648. <dd><p>Returns this service’s name.</p>
  1649. <table class="docutils field-list" frame="void" rules="none">
  1650. <col class="field-name" />
  1651. <col class="field-body" />
  1652. <tbody valign="top">
  1653. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The service name.</td>
  1654. </tr>
  1655. </tbody>
  1656. </table>
  1657. </dd></dl>
  1658. </dd></dl>
  1659. </div>
  1660. <div class="section" id="service-side-interceptor">
  1661. <h2>Service-Side Interceptor<a class="headerlink" href="#service-side-interceptor" title="Permalink to this headline">¶</a></h2>
  1662. <dl class="class">
  1663. <dt id="grpc.ServerInterceptor">
  1664. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">ServerInterceptor</code><a class="reference internal" href="_modules/grpc.html#ServerInterceptor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServerInterceptor" title="Permalink to this definition">¶</a></dt>
  1665. <dd><p>Affords intercepting incoming RPCs on the service-side.</p>
  1666. <p>This is an EXPERIMENTAL API.</p>
  1667. <dl class="method">
  1668. <dt id="grpc.ServerInterceptor.intercept_service">
  1669. <code class="descname">intercept_service</code><span class="sig-paren">(</span><em>continuation</em>, <em>handler_call_details</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#ServerInterceptor.intercept_service"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.ServerInterceptor.intercept_service" title="Permalink to this definition">¶</a></dt>
  1670. <dd><p>Intercepts incoming RPCs before handing them over to a handler.</p>
  1671. <table class="docutils field-list" frame="void" rules="none">
  1672. <col class="field-name" />
  1673. <col class="field-body" />
  1674. <tbody valign="top">
  1675. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1676. <li><strong>continuation</strong> – A function that takes a HandlerCallDetails and
  1677. proceeds to invoke the next interceptor in the chain, if any,
  1678. or the RPC handler lookup logic, with the call details passed
  1679. as an argument, and returns an RpcMethodHandler instance if
  1680. the RPC is considered serviced, or None otherwise.</li>
  1681. <li><strong>handler_call_details</strong> – A HandlerCallDetails describing the RPC.</li>
  1682. </ul>
  1683. </td>
  1684. </tr>
  1685. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An RpcMethodHandler with which the RPC may be serviced if the
  1686. interceptor chooses to service this RPC, or None otherwise.</p>
  1687. </td>
  1688. </tr>
  1689. </tbody>
  1690. </table>
  1691. </dd></dl>
  1692. </dd></dl>
  1693. </div>
  1694. <div class="section" id="multi-callable">
  1695. <h2>Multi-Callable<a class="headerlink" href="#multi-callable" title="Permalink to this headline">¶</a></h2>
  1696. <dl class="class">
  1697. <dt id="grpc.UnaryUnaryMultiCallable">
  1698. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">UnaryUnaryMultiCallable</code><a class="reference internal" href="_modules/grpc.html#UnaryUnaryMultiCallable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryUnaryMultiCallable" title="Permalink to this definition">¶</a></dt>
  1699. <dd><p>Affords invoking a unary-unary RPC from client-side.</p>
  1700. <dl class="method">
  1701. <dt id="grpc.UnaryUnaryMultiCallable.__call__">
  1702. <code class="descname">__call__</code><span class="sig-paren">(</span><em>request</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#UnaryUnaryMultiCallable.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryUnaryMultiCallable.__call__" title="Permalink to this definition">¶</a></dt>
  1703. <dd><p>Synchronously invokes the underlying RPC.</p>
  1704. <table class="docutils field-list" frame="void" rules="none">
  1705. <col class="field-name" />
  1706. <col class="field-body" />
  1707. <tbody valign="top">
  1708. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1709. <li><strong>request</strong> – The request value for the RPC.</li>
  1710. <li><strong>timeout</strong> – An optional duration of time in seconds to allow
  1711. for the RPC.</li>
  1712. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1713. service-side of the RPC.</li>
  1714. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1715. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1716. mechanism</li>
  1717. </ul>
  1718. </td>
  1719. </tr>
  1720. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The response value for the RPC.</p>
  1721. </td>
  1722. </tr>
  1723. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference internal" href="#grpc.RpcError" title="grpc.RpcError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RpcError</span></code></a> – Indicating that the RPC terminated with non-OK status. The
  1724. raised RpcError will also be a Call for the RPC affording the RPC’s
  1725. metadata, status code, and details.</p>
  1726. </td>
  1727. </tr>
  1728. </tbody>
  1729. </table>
  1730. </dd></dl>
  1731. <dl class="method">
  1732. <dt id="grpc.UnaryUnaryMultiCallable.future">
  1733. <code class="descname">future</code><span class="sig-paren">(</span><em>request</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#UnaryUnaryMultiCallable.future"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryUnaryMultiCallable.future" title="Permalink to this definition">¶</a></dt>
  1734. <dd><p>Asynchronously invokes the underlying RPC.</p>
  1735. <table class="docutils field-list" frame="void" rules="none">
  1736. <col class="field-name" />
  1737. <col class="field-body" />
  1738. <tbody valign="top">
  1739. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1740. <li><strong>request</strong> – The request value for the RPC.</li>
  1741. <li><strong>timeout</strong> – An optional duration of time in seconds to allow for
  1742. the RPC.</li>
  1743. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1744. service-side of the RPC.</li>
  1745. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1746. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1747. mechanism</li>
  1748. </ul>
  1749. </td>
  1750. </tr>
  1751. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and a Future.
  1752. In the event of RPC completion, the return Call-Future’s result
  1753. value will be the response message of the RPC.
  1754. Should the event terminate with non-OK status,
  1755. the returned Call-Future’s exception value will be an RpcError.</p>
  1756. </td>
  1757. </tr>
  1758. </tbody>
  1759. </table>
  1760. </dd></dl>
  1761. <dl class="method">
  1762. <dt id="grpc.UnaryUnaryMultiCallable.with_call">
  1763. <code class="descname">with_call</code><span class="sig-paren">(</span><em>request</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#UnaryUnaryMultiCallable.with_call"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryUnaryMultiCallable.with_call" title="Permalink to this definition">¶</a></dt>
  1764. <dd><p>Synchronously invokes the underlying RPC.</p>
  1765. <table class="docutils field-list" frame="void" rules="none">
  1766. <col class="field-name" />
  1767. <col class="field-body" />
  1768. <tbody valign="top">
  1769. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1770. <li><strong>request</strong> – The request value for the RPC.</li>
  1771. <li><strong>timeout</strong> – An optional durating of time in seconds to allow for
  1772. the RPC.</li>
  1773. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1774. service-side of the RPC.</li>
  1775. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1776. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1777. mechanism</li>
  1778. </ul>
  1779. </td>
  1780. </tr>
  1781. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The response value for the RPC and a Call value for the RPC.</p>
  1782. </td>
  1783. </tr>
  1784. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference internal" href="#grpc.RpcError" title="grpc.RpcError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RpcError</span></code></a> – Indicating that the RPC terminated with non-OK status. The
  1785. raised RpcError will also be a Call for the RPC affording the RPC’s
  1786. metadata, status code, and details.</p>
  1787. </td>
  1788. </tr>
  1789. </tbody>
  1790. </table>
  1791. </dd></dl>
  1792. </dd></dl>
  1793. <dl class="class">
  1794. <dt id="grpc.UnaryStreamMultiCallable">
  1795. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">UnaryStreamMultiCallable</code><a class="reference internal" href="_modules/grpc.html#UnaryStreamMultiCallable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryStreamMultiCallable" title="Permalink to this definition">¶</a></dt>
  1796. <dd><p>Affords invoking a unary-stream RPC from client-side.</p>
  1797. <dl class="method">
  1798. <dt id="grpc.UnaryStreamMultiCallable.__call__">
  1799. <code class="descname">__call__</code><span class="sig-paren">(</span><em>request</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#UnaryStreamMultiCallable.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.UnaryStreamMultiCallable.__call__" title="Permalink to this definition">¶</a></dt>
  1800. <dd><p>Invokes the underlying RPC.</p>
  1801. <table class="docutils field-list" frame="void" rules="none">
  1802. <col class="field-name" />
  1803. <col class="field-body" />
  1804. <tbody valign="top">
  1805. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1806. <li><strong>request</strong> – The request value for the RPC.</li>
  1807. <li><strong>timeout</strong> – An optional duration of time in seconds to allow for
  1808. the RPC. If None, the timeout is considered infinite.</li>
  1809. <li><strong>metadata</strong> – An optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1810. service-side of the RPC.</li>
  1811. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1812. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1813. mechanism</li>
  1814. </ul>
  1815. </td>
  1816. </tr>
  1817. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and an iterator of
  1818. response values. Drawing response values from the returned
  1819. Call-iterator may raise RpcError indicating termination of the
  1820. RPC with non-OK status.</p>
  1821. </td>
  1822. </tr>
  1823. </tbody>
  1824. </table>
  1825. </dd></dl>
  1826. </dd></dl>
  1827. <dl class="class">
  1828. <dt id="grpc.StreamUnaryMultiCallable">
  1829. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">StreamUnaryMultiCallable</code><a class="reference internal" href="_modules/grpc.html#StreamUnaryMultiCallable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamUnaryMultiCallable" title="Permalink to this definition">¶</a></dt>
  1830. <dd><p>Affords invoking a stream-unary RPC from client-side.</p>
  1831. <dl class="method">
  1832. <dt id="grpc.StreamUnaryMultiCallable.__call__">
  1833. <code class="descname">__call__</code><span class="sig-paren">(</span><em>request_iterator</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#StreamUnaryMultiCallable.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamUnaryMultiCallable.__call__" title="Permalink to this definition">¶</a></dt>
  1834. <dd><p>Synchronously invokes the underlying RPC.</p>
  1835. <table class="docutils field-list" frame="void" rules="none">
  1836. <col class="field-name" />
  1837. <col class="field-body" />
  1838. <tbody valign="top">
  1839. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1840. <li><strong>request_iterator</strong> – An iterator that yields request values for
  1841. the RPC.</li>
  1842. <li><strong>timeout</strong> – An optional duration of time in seconds to allow for
  1843. the RPC. If None, the timeout is considered infinite.</li>
  1844. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1845. service-side of the RPC.</li>
  1846. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1847. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1848. mechanism</li>
  1849. </ul>
  1850. </td>
  1851. </tr>
  1852. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The response value for the RPC.</p>
  1853. </td>
  1854. </tr>
  1855. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference internal" href="#grpc.RpcError" title="grpc.RpcError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RpcError</span></code></a> – Indicating that the RPC terminated with non-OK status. The
  1856. raised RpcError will also implement grpc.Call, affording methods
  1857. such as metadata, code, and details.</p>
  1858. </td>
  1859. </tr>
  1860. </tbody>
  1861. </table>
  1862. </dd></dl>
  1863. <dl class="method">
  1864. <dt id="grpc.StreamUnaryMultiCallable.future">
  1865. <code class="descname">future</code><span class="sig-paren">(</span><em>request_iterator</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#StreamUnaryMultiCallable.future"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamUnaryMultiCallable.future" title="Permalink to this definition">¶</a></dt>
  1866. <dd><p>Asynchronously invokes the underlying RPC on the client.</p>
  1867. <table class="docutils field-list" frame="void" rules="none">
  1868. <col class="field-name" />
  1869. <col class="field-body" />
  1870. <tbody valign="top">
  1871. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1872. <li><strong>request_iterator</strong> – An iterator that yields request values for the RPC.</li>
  1873. <li><strong>timeout</strong> – An optional duration of time in seconds to allow for
  1874. the RPC. If None, the timeout is considered infinite.</li>
  1875. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1876. service-side of the RPC.</li>
  1877. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1878. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1879. mechanism</li>
  1880. </ul>
  1881. </td>
  1882. </tr>
  1883. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and a Future.
  1884. In the event of RPC completion, the return Call-Future’s result value
  1885. will be the response message of the RPC. Should the event terminate
  1886. with non-OK status, the returned Call-Future’s exception value will
  1887. be an RpcError.</p>
  1888. </td>
  1889. </tr>
  1890. </tbody>
  1891. </table>
  1892. </dd></dl>
  1893. <dl class="method">
  1894. <dt id="grpc.StreamUnaryMultiCallable.with_call">
  1895. <code class="descname">with_call</code><span class="sig-paren">(</span><em>request_iterator</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#StreamUnaryMultiCallable.with_call"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamUnaryMultiCallable.with_call" title="Permalink to this definition">¶</a></dt>
  1896. <dd><p>Synchronously invokes the underlying RPC on the client.</p>
  1897. <table class="docutils field-list" frame="void" rules="none">
  1898. <col class="field-name" />
  1899. <col class="field-body" />
  1900. <tbody valign="top">
  1901. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1902. <li><strong>request_iterator</strong> – An iterator that yields request values for
  1903. the RPC.</li>
  1904. <li><strong>timeout</strong> – An optional duration of time in seconds to allow for
  1905. the RPC. If None, the timeout is considered infinite.</li>
  1906. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1907. service-side of the RPC.</li>
  1908. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1909. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1910. mechanism</li>
  1911. </ul>
  1912. </td>
  1913. </tr>
  1914. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The response value for the RPC and a Call object for the RPC.</p>
  1915. </td>
  1916. </tr>
  1917. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><a class="reference internal" href="#grpc.RpcError" title="grpc.RpcError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RpcError</span></code></a> – Indicating that the RPC terminated with non-OK status. The
  1918. raised RpcError will also be a Call for the RPC affording the RPC’s
  1919. metadata, status code, and details.</p>
  1920. </td>
  1921. </tr>
  1922. </tbody>
  1923. </table>
  1924. </dd></dl>
  1925. </dd></dl>
  1926. <dl class="class">
  1927. <dt id="grpc.StreamStreamMultiCallable">
  1928. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">StreamStreamMultiCallable</code><a class="reference internal" href="_modules/grpc.html#StreamStreamMultiCallable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamStreamMultiCallable" title="Permalink to this definition">¶</a></dt>
  1929. <dd><p>Affords invoking a stream-stream RPC on client-side.</p>
  1930. <dl class="method">
  1931. <dt id="grpc.StreamStreamMultiCallable.__call__">
  1932. <code class="descname">__call__</code><span class="sig-paren">(</span><em>request_iterator</em>, <em>timeout=None</em>, <em>metadata=None</em>, <em>credentials=None</em>, <em>wait_for_ready=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#StreamStreamMultiCallable.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.StreamStreamMultiCallable.__call__" title="Permalink to this definition">¶</a></dt>
  1933. <dd><p>Invokes the underlying RPC on the client.</p>
  1934. <table class="docutils field-list" frame="void" rules="none">
  1935. <col class="field-name" />
  1936. <col class="field-body" />
  1937. <tbody valign="top">
  1938. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  1939. <li><strong>request_iterator</strong> – An iterator that yields request values for the RPC.</li>
  1940. <li><strong>timeout</strong> – An optional duration of time in seconds to allow for
  1941. the RPC. If not specified, the timeout is considered infinite.</li>
  1942. <li><strong>metadata</strong> – Optional <a class="reference internal" href="glossary.html#term-metadata"><span class="xref std std-term">metadata</span></a> to be transmitted to the
  1943. service-side of the RPC.</li>
  1944. <li><strong>credentials</strong> – An optional CallCredentials for the RPC.</li>
  1945. <li><strong>wait_for_ready</strong> – An optional flag to enable wait for ready
  1946. mechanism</li>
  1947. </ul>
  1948. </td>
  1949. </tr>
  1950. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">An object that is both a Call for the RPC and an iterator of
  1951. response values. Drawing response values from the returned
  1952. Call-iterator may raise RpcError indicating termination of the
  1953. RPC with non-OK status.</p>
  1954. </td>
  1955. </tr>
  1956. </tbody>
  1957. </table>
  1958. </dd></dl>
  1959. </dd></dl>
  1960. </div>
  1961. <div class="section" id="future">
  1962. <h2>Future<a class="headerlink" href="#future" title="Permalink to this headline">¶</a></h2>
  1963. <dl class="exception">
  1964. <dt id="grpc.FutureTimeoutError">
  1965. <em class="property">exception </em><code class="descclassname">grpc.</code><code class="descname">FutureTimeoutError</code><a class="reference internal" href="_modules/grpc.html#FutureTimeoutError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.FutureTimeoutError" title="Permalink to this definition">¶</a></dt>
  1966. <dd><p>Indicates that a method call on a Future timed out.</p>
  1967. </dd></dl>
  1968. <dl class="exception">
  1969. <dt id="grpc.FutureCancelledError">
  1970. <em class="property">exception </em><code class="descclassname">grpc.</code><code class="descname">FutureCancelledError</code><a class="reference internal" href="_modules/grpc.html#FutureCancelledError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.FutureCancelledError" title="Permalink to this definition">¶</a></dt>
  1971. <dd><p>Indicates that the computation underlying a Future was cancelled.</p>
  1972. </dd></dl>
  1973. <dl class="class">
  1974. <dt id="grpc.Future">
  1975. <em class="property">class </em><code class="descclassname">grpc.</code><code class="descname">Future</code><a class="reference internal" href="_modules/grpc.html#Future"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future" title="Permalink to this definition">¶</a></dt>
  1976. <dd><p>A representation of a computation in another control flow.</p>
  1977. <p>Computations represented by a Future may be yet to be begun,
  1978. may be ongoing, or may have already completed.</p>
  1979. <dl class="method">
  1980. <dt id="grpc.Future.add_done_callback">
  1981. <code class="descname">add_done_callback</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.add_done_callback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.add_done_callback" title="Permalink to this definition">¶</a></dt>
  1982. <dd><p>Adds a function to be called at completion of the computation.</p>
  1983. <p>The callback will be passed this Future object describing the outcome
  1984. of the computation. Callbacks will be invoked after the future is
  1985. terimated, whether successfully or not.</p>
  1986. <p>If the computation has already completed, the callback will be called
  1987. immediately.</p>
  1988. <table class="docutils field-list" frame="void" rules="none">
  1989. <col class="field-name" />
  1990. <col class="field-body" />
  1991. <tbody valign="top">
  1992. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>fn</strong> – A callable taking this Future object as its single parameter.</td>
  1993. </tr>
  1994. </tbody>
  1995. </table>
  1996. </dd></dl>
  1997. <dl class="method">
  1998. <dt id="grpc.Future.cancel">
  1999. <code class="descname">cancel</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.cancel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.cancel" title="Permalink to this definition">¶</a></dt>
  2000. <dd><p>Attempts to cancel the computation.</p>
  2001. <p>This method does not block.</p>
  2002. <table class="docutils field-list" frame="void" rules="none">
  2003. <col class="field-name" />
  2004. <col class="field-body" />
  2005. <tbody valign="top">
  2006. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Returns True if the computation was canceled.<p>Returns False under all other circumstances, for example:</p>
  2007. <ol class="arabic simple">
  2008. <li>computation has begun and could not be canceled.</li>
  2009. <li>computation has finished</li>
  2010. <li><dl class="first docutils">
  2011. <dt>computation is scheduled for execution and it is impossible</dt>
  2012. <dd>to determine its state without blocking.</dd>
  2013. </dl>
  2014. </li>
  2015. </ol>
  2016. </td>
  2017. </tr>
  2018. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  2019. </tr>
  2020. </tbody>
  2021. </table>
  2022. </dd></dl>
  2023. <dl class="method">
  2024. <dt id="grpc.Future.cancelled">
  2025. <code class="descname">cancelled</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.cancelled"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.cancelled" title="Permalink to this definition">¶</a></dt>
  2026. <dd><p>Describes whether the computation was cancelled.</p>
  2027. <p>This method does not block.</p>
  2028. <table class="docutils field-list" frame="void" rules="none">
  2029. <col class="field-name" />
  2030. <col class="field-body" />
  2031. <tbody valign="top">
  2032. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Returns True if the computation was cancelled before its result became
  2033. available.<p>Returns False under all other circumstances, for example:</p>
  2034. <ol class="arabic simple">
  2035. <li>computation was not cancelled.</li>
  2036. <li>computation’s result is available.</li>
  2037. </ol>
  2038. </td>
  2039. </tr>
  2040. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  2041. </tr>
  2042. </tbody>
  2043. </table>
  2044. </dd></dl>
  2045. <dl class="method">
  2046. <dt id="grpc.Future.done">
  2047. <code class="descname">done</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.done"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.done" title="Permalink to this definition">¶</a></dt>
  2048. <dd><p>Describes whether the computation has taken place.</p>
  2049. <p>This method does not block.</p>
  2050. <table class="docutils field-list" frame="void" rules="none">
  2051. <col class="field-name" />
  2052. <col class="field-body" />
  2053. <tbody valign="top">
  2054. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Returns True if the computation already executed or was cancelled.
  2055. Returns False if the computation is scheduled for execution or
  2056. currently executing.
  2057. This is exactly opposite of the running() method’s result.</td>
  2058. </tr>
  2059. <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
  2060. </tr>
  2061. </tbody>
  2062. </table>
  2063. </dd></dl>
  2064. <dl class="method">
  2065. <dt id="grpc.Future.exception">
  2066. <code class="descname">exception</code><span class="sig-paren">(</span><em>timeout=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.exception"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.exception" title="Permalink to this definition">¶</a></dt>
  2067. <dd><p>Return the exception raised by the computation.</p>
  2068. <p>This method may return immediately or may block.</p>
  2069. <table class="docutils field-list" frame="void" rules="none">
  2070. <col class="field-name" />
  2071. <col class="field-body" />
  2072. <tbody valign="top">
  2073. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>timeout</strong> – The length of time in seconds to wait for the computation to
  2074. terminate or be cancelled. If None, the call will block until the
  2075. computations’s termination.</p>
  2076. </td>
  2077. </tr>
  2078. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The exception raised by the computation, or None if the computation
  2079. did not raise an exception.</p>
  2080. </td>
  2081. </tr>
  2082. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  2083. <li><a class="reference internal" href="#grpc.FutureTimeoutError" title="grpc.FutureTimeoutError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureTimeoutError</span></code></a> – If a timeout value is passed and the computation
  2084. does not terminate within the allotted time.</li>
  2085. <li><a class="reference internal" href="#grpc.FutureCancelledError" title="grpc.FutureCancelledError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureCancelledError</span></code></a> – If the computation was cancelled.</li>
  2086. </ul>
  2087. </td>
  2088. </tr>
  2089. </tbody>
  2090. </table>
  2091. </dd></dl>
  2092. <dl class="method">
  2093. <dt id="grpc.Future.result">
  2094. <code class="descname">result</code><span class="sig-paren">(</span><em>timeout=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.result"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.result" title="Permalink to this definition">¶</a></dt>
  2095. <dd><p>Returns the result of the computation or raises its exception.</p>
  2096. <p>This method may return immediately or may block.</p>
  2097. <table class="docutils field-list" frame="void" rules="none">
  2098. <col class="field-name" />
  2099. <col class="field-body" />
  2100. <tbody valign="top">
  2101. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>timeout</strong> – The length of time in seconds to wait for the computation to
  2102. finish or be cancelled. If None, the call will block until the
  2103. computations’s termination.</p>
  2104. </td>
  2105. </tr>
  2106. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The return value of the computation.</p>
  2107. </td>
  2108. </tr>
  2109. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  2110. <li><a class="reference internal" href="#grpc.FutureTimeoutError" title="grpc.FutureTimeoutError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureTimeoutError</span></code></a> – If a timeout value is passed and the computation
  2111. does not terminate within the allotted time.</li>
  2112. <li><a class="reference internal" href="#grpc.FutureCancelledError" title="grpc.FutureCancelledError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureCancelledError</span></code></a> – If the computation was cancelled.</li>
  2113. <li><code class="xref py py-exc docutils literal notranslate"><span class="pre">Exception</span></code> – If the computation raised an exception, this call will
  2114. raise the same exception.</li>
  2115. </ul>
  2116. </td>
  2117. </tr>
  2118. </tbody>
  2119. </table>
  2120. </dd></dl>
  2121. <dl class="method">
  2122. <dt id="grpc.Future.running">
  2123. <code class="descname">running</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.running"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.running" title="Permalink to this definition">¶</a></dt>
  2124. <dd><p>Describes whether the computation is taking place.</p>
  2125. <p>This method does not block.</p>
  2126. <table class="docutils field-list" frame="void" rules="none">
  2127. <col class="field-name" />
  2128. <col class="field-body" />
  2129. <tbody valign="top">
  2130. <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Returns True if the computation is scheduled for execution or
  2131. currently executing.<p>Returns False if the computation already executed or was cancelled.</p>
  2132. </td>
  2133. </tr>
  2134. </tbody>
  2135. </table>
  2136. </dd></dl>
  2137. <dl class="method">
  2138. <dt id="grpc.Future.traceback">
  2139. <code class="descname">traceback</code><span class="sig-paren">(</span><em>timeout=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/grpc.html#Future.traceback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#grpc.Future.traceback" title="Permalink to this definition">¶</a></dt>
  2140. <dd><p>Access the traceback of the exception raised by the computation.</p>
  2141. <p>This method may return immediately or may block.</p>
  2142. <table class="docutils field-list" frame="void" rules="none">
  2143. <col class="field-name" />
  2144. <col class="field-body" />
  2145. <tbody valign="top">
  2146. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>timeout</strong> – The length of time in seconds to wait for the computation
  2147. to terminate or be cancelled. If None, the call will block until
  2148. the computation’s termination.</p>
  2149. </td>
  2150. </tr>
  2151. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The traceback of the exception raised by the computation, or None
  2152. if the computation did not raise an exception.</p>
  2153. </td>
  2154. </tr>
  2155. <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
  2156. <li><a class="reference internal" href="#grpc.FutureTimeoutError" title="grpc.FutureTimeoutError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureTimeoutError</span></code></a> – If a timeout value is passed and the computation
  2157. does not terminate within the allotted time.</li>
  2158. <li><a class="reference internal" href="#grpc.FutureCancelledError" title="grpc.FutureCancelledError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FutureCancelledError</span></code></a> – If the computation was cancelled.</li>
  2159. </ul>
  2160. </td>
  2161. </tr>
  2162. </tbody>
  2163. </table>
  2164. </dd></dl>
  2165. </dd></dl>
  2166. </div>
  2167. </div>
  2168. </div>
  2169. </div>
  2170. </div>
  2171. <div class="clearer"></div>
  2172. </div>
  2173. <div class="footer">
  2174. &copy;2018, The gRPC Authors.
  2175. |
  2176. <a href="_sources/api.rst.txt"
  2177. rel="nofollow">Page source</a>
  2178. </div>
  2179. <script type="text/javascript">
  2180. var _gaq = _gaq || [];
  2181. _gaq.push(['_setAccount', 'UA-60127042-1']);
  2182. _gaq.push(['_setDomainName', 'none']);
  2183. _gaq.push(['_setAllowLinker', true]);
  2184. _gaq.push(['_trackPageview']);
  2185. (function() {
  2186. var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  2187. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  2188. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  2189. })();
  2190. </script>
  2191. </body>
  2192. </html>