Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is asyncio supported? #235

Open
viteski opened this issue Aug 15, 2023 · 1 comment
Open

Is asyncio supported? #235

viteski opened this issue Aug 15, 2023 · 1 comment

Comments

@viteski
Copy link

viteski commented Aug 15, 2023

Hi, I am trying to use shiv to deploy an executable for an asyncio based app using poetry as the build tool and I am running into a coroutine not awaited error that I can't see where it stems from; can you point me in the right direction? is this something you have seen before?. I have the following project tree:

Project-name
   src
     build.sh
     project_name
       __init__.py
       __main__.py
       app.py
       **.py

build.sh

shiv -p "$interpreter" -e bacnet_client.app:main --site-packages "$site_path" -o dist/project_name.pyz
python3.10 dist/project_name.pyz

main.py

import asyncio
import bacnet_client as app


async def main():
    await app.main()

if __name__ == "__main__":
    asyncio.run(main())

app.py

import asyncio
import logging
import queue
import json
import re
from logging.handlers import QueueHandler
async def main():
    """
    Run or schedule all your services from this entry-point script.
    """

    try:
        loop = asyncio.get_running_loop()
        logQ = queue.Queue()
        logProducer = QueueHandler(logQ)
        logProducer.setFormatter(JsonFormatter(datefmt=ISO8601))
        logger = logging.getLogger('ClientLog')
        logger.addHandler(logProducer)
        logger.setLevel(logging.DEBUG)
        logger_task = loop.create_task(log(logQ))
        await logger_task
    finally:
        logger.info("Client application stopping:")
        logger.info(None)
        logger_task.cancel()

if __name__ == "__main__":
    asyncio.run(main())

Ultimately the error output after running build.sh is as follows:
<coroutine object main at 0x7f62e17037d0>
sys:1: RuntimeWarning: coroutine 'main' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

PS.
I did import the tracemalloc and wired some functions into the app.py's main function and __main__.py but it failed with the same error and tracemalloc did not provide any output.

Thank you so much.

@rayate2410
Copy link

I'm facing similar issue when I'm trying to use this with a tornado application. Getting below error.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants