Skip to content

Commit

Permalink
fixes: #222
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Sep 13, 2020
1 parent ccd578b commit 7236f20
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions idom/core/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,18 @@ def __repr__(self) -> str:

class _ElementQueue:

__slots__ = "_queue", "_pending"
__slots__ = "_loop", "_queue", "_pending"

def __init__(self) -> None:
self._loop = asyncio.get_event_loop()
self._queue: "asyncio.Queue[AbstractElement]" = asyncio.Queue()
self._pending: Set[int] = set()

def put(self, element: AbstractElement) -> None:
element_id = id(element)
if element_id not in self._pending:
self._pending.add(element_id)
self._queue.put_nowait(element)
self._loop.call_soon_threadsafe(self._queue.put_nowait, element)
return None

async def get(self) -> AbstractElement:
Expand Down

0 comments on commit 7236f20

Please sign in to comment.