grpc.html 145 KB

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