async def call(self, func: FunctionWithSource) -> None: try: frame = from_channel(self._initializer["frame"]) source = dict(context=frame._page.context, page=frame._page, frame=frame) func_args = list(map(parse_result, self._initializer["args"])) result = func(source, *func_args) if asyncio.isfuture(result): result = await result await self._channel.send("resolve", dict(result=serialize_argument(result))) except Exception as e: tb = sys.exc_info()[2] asyncio.create_task( self._channel.send("reject", dict(error=serialize_error(e, tb))) )
async def call(self, func: FunctionWithSource) -> None: try: frame = from_channel(self._initializer["frame"]) source = dict(context=frame._page.context, page=frame._page, frame=frame) result = func(source, *self._initializer["args"]) if isinstance(result, asyncio.Future): result = await result await self._channel.send("resolve", dict(result=result)) except Exception as e: tb = sys.exc_info()[2] asyncio.ensure_future( self._channel.send("reject", dict(error=serialize_error(e, tb))))