async def main(start_port: int, show_timing: bool = False, interactive: bool = True): genesis = None # await default_genesis_txns() #if not genesis: # print("Error retrieving ledger genesis transactions") # sys.exit(1) agent = None try: agent = AfGoAgentBackchannel("aca-py", start_port + 1, start_port + 2, genesis_data=genesis) # start backchannel (common across all types of agents) await agent.listen_backchannel(start_port) # start aca-py agent sub-process and listen for web hooks await agent.listen_webhooks(start_port + 3) # await agent.register_did() await agent.start_process() agent.activate() # now wait ... if interactive: async for option in prompt_loop("(X) Exit? [X] "): if option is None or option in "xX": break else: print("Press Ctrl-C to exit ...") remaining_tasks = asyncio.Task.all_tasks() await asyncio.gather(*remaining_tasks) finally: terminated = True try: if agent: await agent.terminate() except Exception: LOGGER.exception("Error terminating agent:") terminated = False await asyncio.sleep(0.1) if not terminated: os._exit(1)
async def main(start_port: int, show_timing: bool = False, interactive: bool = True): genesis = None agent = None agent_ports = AgentPorts( http=start_port + 1, admin=start_port + 2, ws=start_port + 3, ) try: print("Starting mobile backchannel ...") agent = MobileAgentBackchannel("mobile", agent_ports, genesis_data=genesis) # start backchannel (common across all types of agents) await agent.listen_backchannel(start_port) agent.activate() # now wait ... if interactive: async for option in prompt_loop("(X) Exit? [X] "): if option is None or option in "xX": break else: print("Press Ctrl-C to exit ...") remaining_tasks = asyncio.Task.all_tasks() await asyncio.gather(*remaining_tasks) finally: terminated = True try: if agent: await agent.terminate() except Exception: LOGGER.exception("Error terminating agent:") terminated = False await asyncio.sleep(0.1) if not terminated: os._exit(1)