beebot icon indicating copy to clipboard operation
beebot copied to clipboard

sys:1: RuntimeWarning: coroutine 'main' was never awaited

Open simjak opened this issue 1 year ago • 1 comments

<coroutine object main at 0x1034b0f40>
sys:1: RuntimeWarning: coroutine 'main' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

simjak avatar Aug 24 '23 05:08 simjak

The problem is in the pyproject.toml the script is described as follows:

[tool.poetry.scripts]
beebot = 'beebot.initiator.cli:main'

Which means the async function main from cli.py gets executed when running the command poetry run beebot. To fix it for now, you can make main sync and let it call async_main async like this:

cli.py last part with the main function to this:

async def async_main():
    load_dotenv()
    parsed_args = parse_args()
    if parsed_args.task:
        task = parsed_args.task
    else:
        print("What would you like me to do?")
        print("> ", end="")
        task = input()

    config = Config.global_config()
    config.setup_logging()
    await initialize_db(config.database_url)

    body = Body(task=task, config=config)
    await body.setup()
    while output := await body.cycle():
        if output.observation:
            print("\n=== Cycle Output ===")
            print(output.observation.response)


def main():
    asyncio.run(async_main())


if __name__ == "__main__":
    main()

Avejack avatar Aug 24 '23 15:08 Avejack