Skip to content

Instantly share code, notes, and snippets.

View daemotron's full-sized avatar
refuelling

Jesco Freund daemotron

refuelling
View GitHub Profile
@daemotron
daemotron / client.py
Created September 10, 2021 11:09 — forked from bashkirtsevich/client.py
asyncio UDP client
import asyncio
class EchoClientProtocol:
def __init__(self, message, loop):
self.message = message
self.loop = loop
self.transport = None
def connection_made(self, transport):
self.transport = transport
@daemotron
daemotron / asyncio_loops.py
Created September 9, 2021 09:28 — forked from lars-tiede/asyncio_loops.py
asyncio + multithreading: one asyncio event loop per thread
import asyncio
import threading
import random
def thr(i):
# we need to create a new loop for the thread, and set it as the 'default'
# loop that will be returned by calls to asyncio.get_event_loop() from this
# thread.
loop = asyncio.new_event_loop()