continue-custom/server/continuedev/libs/util/queue.py
Nate Sesti 279593a848
Strong typing (#533)
* refactor: ♻️ get rid of continuedev.src.continuedev structure

* refactor: ♻️ switching back to server folder

* feat: ✨ make config.py imports shorter

* feat: 🔖 publish as pre-release vscode extension

* refactor: ♻️ refactor and add more completion params to ui

* build: 🏗️ download from preview S3
2023-10-04 23:47:59 -07:00

17 lines
597 B
Python

import asyncio
from typing import Dict
class AsyncSubscriptionQueue:
# The correct way to do this is probably to keep request IDs
queues: Dict[str, asyncio.Queue] = {}
def post(self, messageType: str, data: any):
if messageType not in self.queues:
self.queues.update({messageType: asyncio.Queue()})
self.queues[messageType].put_nowait(data)
async def get(self, message_type: str) -> any:
if message_type not in self.queues:
self.queues.update({message_type: asyncio.Queue()})
return await self.queues[message_type].get()