File size: 727 Bytes
cb92d2b
 
ff9325e
cb92d2b
ff9325e
cb92d2b
 
ff9325e
cb92d2b
ff9325e
cb92d2b
 
ff9325e
 
 
 
 
 
 
 
 
 
 
 
 
cb92d2b
 
ff9325e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from typing import Dict, Union
from uuid import UUID
import asyncio
from PIL import Image
from typing import Dict, Union
from PIL import Image

InputParams = dict
UserId = UUID
EventDataContent = Dict[str, InputParams]


class UserDataEvent:
    def __init__(self):
        self.data_event = asyncio.Event()
        self.data_content: EventDataContent = {}

    def update_data(self, new_data: EventDataContent):
        self.data_content = new_data
        self.data_event.set()

    async def wait_for_data(self) -> EventDataContent:
        await self.data_event.wait()
        self.data_event.clear()
        return self.data_content


UserDataEventMap = Dict[UserId, UserDataEvent]
user_data_events: UserDataEventMap = {}