Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _callback_till_result(kernel, response: Callback, response_type: Type[KernelResponse]) -> Any:
while isinstance(response, Callback):
try:
result = _handle_callback(kernel, response)
except Exception as exc:
response = kernel.sync_complete(response.cbid, str(exc), None, response_type)
else:
response = kernel.sync_complete(response.cbid, None, result, response_type)
if isinstance(response, InvokeResponse):
return response.result
elif isinstance(response, GetResponse):
return response.value
else:
return response
def sinvoke(self, request: StaticInvokeRequest) -> InvokeResponse:
return self._process.send(request, InvokeResponse)
def invoke(self, request: InvokeRequest) -> Union[InvokeResponse, Callback]:
return self._process.send(request, InvokeResponse)
def invoke(
self, obj: Referenceable, method: str, args: Optional[List[Any]] = None
) -> Any:
if args is None:
args = []
response = self.provider.invoke(
InvokeRequest(
objref=obj.__jsii_ref__,
method=method,
args=_make_reference_for_native(self, args),
)
)
if isinstance(response, Callback):
return _callback_till_result(self, response, InvokeResponse)
else:
return response.result