How to run 2 loops at the same time using asyncio

Viewed 795

I'm pretty new to asyncio, so lot of things are still way too far from my understanding yet, anyway.

I got a main while loop that basically just draws some stuff on the screen using PyGame, and what i'd like to do, is to run another while loop asynchronously, that keeps updating some data to be rendered.

async def update(reader, writer):
    while True:
        json_data = await reader.read(1000)
        self.json_data = json.loads(json_data)

def run(self):
    while True:
        self.draw()
1 Answers
Related