grpc.html 137 KB

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