# # Autogenerated by Thrift # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @generated # cimport cython from typing import AsyncIterator from cpython.version cimport PY_VERSION_HEX from libc.stdint cimport ( int8_t as cint8_t, int16_t as cint16_t, int32_t as cint32_t, int64_t as cint64_t, ) from libcpp.memory cimport shared_ptr, make_shared, unique_ptr from libcpp.string cimport string from libcpp cimport bool as cbool from cpython cimport bool as pbool from libcpp.vector cimport vector from libcpp.set cimport set as cset from libcpp.map cimport map as cmap from libcpp.utility cimport move as cmove from libcpp.pair cimport pair from cython.operator cimport dereference as deref from cpython.ref cimport PyObject from thrift.py3.exceptions cimport ( cTApplicationException, ApplicationError as __ApplicationError, cTApplicationExceptionType__UNKNOWN) from thrift.py3.server cimport ServiceInterface, RequestContext, Cpp2RequestContext from thrift.py3.server import RequestContext from folly cimport ( cFollyPromise, cFollyUnit, c_unit, ) from thrift.py3.common cimport ( cThriftServiceMetadataResponse as __fbthrift_cThriftServiceMetadataResponse, ServiceMetadata, MetadataBox as __MetadataBox, ) from thrift.py3.server cimport THRIFT_REQUEST_CONTEXT as __THRIFT_REQUEST_CONTEXT from thrift.py3.types cimport make_unique cimport folly.futures from folly.executor cimport get_executor cimport folly.iobuf as _fbthrift_iobuf import folly.iobuf as _fbthrift_iobuf from folly.iobuf cimport move as move_iobuf from folly.memory cimport to_shared_ptr as __to_shared_ptr cimport module.types as _module_types import module.types as _module_types cimport module.services_reflection as _services_reflection import asyncio import functools import sys import traceback import types as _py_types from module.services_wrapper cimport cMyRootInterface from module.services_wrapper cimport cMyNodeInterface from module.services_wrapper cimport cMyLeafInterface @cython.auto_pickle(False) cdef class Promise_cFollyUnit: cdef cFollyPromise[cFollyUnit]* cPromise def __cinit__(self): self.cPromise = new cFollyPromise[cFollyUnit](cFollyPromise[cFollyUnit].makeEmpty()) def __dealloc__(self): del self.cPromise @staticmethod cdef _fbthrift_create(cFollyPromise[cFollyUnit] cPromise): cdef Promise_cFollyUnit inst = Promise_cFollyUnit.__new__(Promise_cFollyUnit) inst.cPromise[0] = cmove(cPromise) return inst cdef object _MyRoot_annotations = _py_types.MappingProxyType({ }) @cython.auto_pickle(False) cdef class MyRootInterface( ServiceInterface ): annotations = _MyRoot_annotations def __cinit__(self): self._cpp_obj = cMyRootInterface( self, get_executor() ) async def do_root( self): raise NotImplementedError("async def do_root is not implemented") @classmethod def __get_reflection__(cls): return _services_reflection.get_reflection__MyRoot(for_clients=False) @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftServiceMetadataResponse response ServiceMetadata[_services_reflection.cMyRootSvIf].gen(response) return __MetadataBox.box(cmove(deref(response.metadata_ref()))) @staticmethod def __get_thrift_name__(): return "module.MyRoot" cdef object _MyNode_annotations = _py_types.MappingProxyType({ }) @cython.auto_pickle(False) cdef class MyNodeInterface( MyRootInterface ): annotations = _MyNode_annotations def __cinit__(self): self._cpp_obj = cMyNodeInterface( self, get_executor() ) async def do_mid( self): raise NotImplementedError("async def do_mid is not implemented") @classmethod def __get_reflection__(cls): return _services_reflection.get_reflection__MyNode(for_clients=False) @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftServiceMetadataResponse response ServiceMetadata[_services_reflection.cMyNodeSvIf].gen(response) return __MetadataBox.box(cmove(deref(response.metadata_ref()))) @staticmethod def __get_thrift_name__(): return "module.MyNode" cdef object _MyLeaf_annotations = _py_types.MappingProxyType({ }) @cython.auto_pickle(False) cdef class MyLeafInterface( MyNodeInterface ): annotations = _MyLeaf_annotations def __cinit__(self): self._cpp_obj = cMyLeafInterface( self, get_executor() ) async def do_leaf( self): raise NotImplementedError("async def do_leaf is not implemented") @classmethod def __get_reflection__(cls): return _services_reflection.get_reflection__MyLeaf(for_clients=False) @staticmethod def __get_metadata__(): cdef __fbthrift_cThriftServiceMetadataResponse response ServiceMetadata[_services_reflection.cMyLeafSvIf].gen(response) return __MetadataBox.box(cmove(deref(response.metadata_ref()))) @staticmethod def __get_thrift_name__(): return "module.MyLeaf" cdef api void call_cy_MyRoot_do_root( object self, Cpp2RequestContext* ctx, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) __context = RequestContext._fbthrift_create(ctx) __context_token = __THRIFT_REQUEST_CONTEXT.set(__context) asyncio.get_event_loop().create_task( MyRoot_do_root_coro( self, __promise ) ) __THRIFT_REQUEST_CONTEXT.reset(__context_token) cdef api void call_cy_MyRoot_onStartServing( object self, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( MyRoot_onStartServing_coro( self, __promise ) ) cdef api void call_cy_MyRoot_onStopRequested( object self, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( MyRoot_onStopRequested_coro( self, __promise ) ) async def MyRoot_do_root_coro( object self, Promise_cFollyUnit promise ): try: result = await self.do_root() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyRoot.do_root:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyRoot.do_root:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) async def MyRoot_onStartServing_coro( object self, Promise_cFollyUnit promise ): try: result = await self.onStartServing() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyRoot.onStartServing:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyRoot.onStartServing:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) async def MyRoot_onStopRequested_coro( object self, Promise_cFollyUnit promise ): try: result = await self.onStopRequested() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyRoot.onStopRequested:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyRoot.onStopRequested:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) cdef api void call_cy_MyNode_do_mid( object self, Cpp2RequestContext* ctx, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) __context = RequestContext._fbthrift_create(ctx) __context_token = __THRIFT_REQUEST_CONTEXT.set(__context) asyncio.get_event_loop().create_task( MyNode_do_mid_coro( self, __promise ) ) __THRIFT_REQUEST_CONTEXT.reset(__context_token) cdef api void call_cy_MyNode_onStartServing( object self, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( MyNode_onStartServing_coro( self, __promise ) ) cdef api void call_cy_MyNode_onStopRequested( object self, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( MyNode_onStopRequested_coro( self, __promise ) ) async def MyNode_do_mid_coro( object self, Promise_cFollyUnit promise ): try: result = await self.do_mid() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyNode.do_mid:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyNode.do_mid:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) async def MyNode_onStartServing_coro( object self, Promise_cFollyUnit promise ): try: result = await self.onStartServing() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyNode.onStartServing:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyNode.onStartServing:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) async def MyNode_onStopRequested_coro( object self, Promise_cFollyUnit promise ): try: result = await self.onStopRequested() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyNode.onStopRequested:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyNode.onStopRequested:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) cdef api void call_cy_MyLeaf_do_leaf( object self, Cpp2RequestContext* ctx, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) __context = RequestContext._fbthrift_create(ctx) __context_token = __THRIFT_REQUEST_CONTEXT.set(__context) asyncio.get_event_loop().create_task( MyLeaf_do_leaf_coro( self, __promise ) ) __THRIFT_REQUEST_CONTEXT.reset(__context_token) cdef api void call_cy_MyLeaf_onStartServing( object self, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( MyLeaf_onStartServing_coro( self, __promise ) ) cdef api void call_cy_MyLeaf_onStopRequested( object self, cFollyPromise[cFollyUnit] cPromise ) noexcept: cdef Promise_cFollyUnit __promise = Promise_cFollyUnit._fbthrift_create(cmove(cPromise)) asyncio.get_event_loop().create_task( MyLeaf_onStopRequested_coro( self, __promise ) ) async def MyLeaf_do_leaf_coro( object self, Promise_cFollyUnit promise ): try: result = await self.do_leaf() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyLeaf.do_leaf:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyLeaf.do_leaf:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) async def MyLeaf_onStartServing_coro( object self, Promise_cFollyUnit promise ): try: result = await self.onStartServing() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyLeaf.onStartServing:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyLeaf.onStartServing:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit) async def MyLeaf_onStopRequested_coro( object self, Promise_cFollyUnit promise ): try: result = await self.onStopRequested() except __ApplicationError as ex: # If the handler raised an ApplicationError convert it to a C++ one promise.cPromise.setException(cTApplicationException( ex.type.value, ex.message.encode('UTF-8') )) except Exception as ex: print( "Unexpected error in service handler MyLeaf.onStopRequested:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, repr(ex).encode('UTF-8') )) except asyncio.CancelledError as ex: print("Coroutine was cancelled in service handler MyLeaf.onStopRequested:", file=sys.stderr) traceback.print_exc() promise.cPromise.setException(cTApplicationException( cTApplicationExceptionType__UNKNOWN, (f'Application was cancelled on the server with message: {str(ex)}').encode('UTF-8') )) else: promise.cPromise.setValue(c_unit)