grpc.html 152 KB

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