This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author greckov
Recipients asvetlov, greckov, yselivanov
Date 2020-12-02.12:17:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hi! I've met strange behaviour related to the coroutine execution. Probably it's somehow related to the asyncio.Queue get() method. I have the following lines of code:
class WeightSource:
    def __init__(self):
        self._queue = asyncio.Queue(maxsize=1)
    def __aiter__(self):
        return self
    async def __anext__(self):
        return await self._queue.get()

async def _preconfigure(app: web.Application) -> None:
    # asyncio.create_task(WeightSource.listen_scales('/dev/ttyACM0', 9600)
    asyncio.create_task(handle_weight_event_creation()) # coroutine prints WEIGHT <int>
    await create_track_tasks()

async def create_track_tasks():

async def track_scales_availability():
    async for weight in WeightSource():

When I'm trying to run _preconfigure coroutine (automatically started by aiohttp), i see the message: ERROR:asyncio:Task was destroyed but it is pending. The strange things two:
The process and loop remains alive (so by the logic error should be not shown) and the second thing is when I export PYTHONASYNCIODEBUG=1 everything works well without any error. 
On unset this variable the error returns. When I don't use asyncio.Queue and just place asyncio.sleep(), coroutine doesn't fall. Error happens inside the `async for weight in WeightSource()` statement. Why PYTHONASYNCIODEBUG changes behaviour?
Date User Action Args
2020-12-02 12:17:27greckovsetrecipients: + greckov, asvetlov, yselivanov
2020-12-02 12:17:27greckovsetmessageid: <>
2020-12-02 12:17:27greckovlinkissue42538 messages
2020-12-02 12:17:27greckovcreate