Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Queue in python 3.5 asserts/hangs with low queue size #268

@obmarg

Description

@obmarg

I've been attempting to update to python 3.5 today, but it has been causing some of our unit tests to fail with an assert error.

I've reproduced in the repl with this code:

import asyncio

@asyncio.coroutine
def consumer(queue, num_expected):
    for _ in range(num_expected):
        yield from queue.get()

@asyncio.coroutine
def producer(queue, num_items):
    for i in range(num_items):
        yield from queue.put(i)


queue_size = 1
producer_num_items = 5
q = asyncio.Queue(queue_size)

results = asyncio.get_event_loop().run_until_complete(
    asyncio.gather(producer(q, producer_num_items),
                   consumer(q, producer_num_items)),
)

This code causes AssertionError: queue non-empty, why are getters waiting? to be thrown. Strangely, if I increase queue_size to 3 or 4, this causes the code to hang. 5 seems to be the magic queue_size that makes problems go away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions