Message260588
I want to have a loop that receives data like this:
socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
socket.bind(('0.0.0.0', port))
socket.setblocking(False)
while True:
data, addr = await loop.sock_recvfrom(sock, 4096)
# process packet
It's pretty similar to what the blocking code would look like, but it allows me to keep everything on a single thread without blocking. It could be done with the Protocol API, but I'd rather use the shiny new async/await API. |
|
Date |
User |
Action |
Args |
2016-02-21 00:47:42 | sbstp | set | recipients:
+ sbstp, gvanrossum, vstinner, yselivanov |
2016-02-21 00:47:42 | sbstp | set | messageid: <1456015662.7.0.00382711667437.issue26395@psf.upfronthosting.co.za> |
2016-02-21 00:47:42 | sbstp | link | issue26395 messages |
2016-02-21 00:47:42 | sbstp | create | |
|