Using python-netfilterqueue with asyncio
dinishi opened this issue · 0 comments
dinishi commented
Hey.
I'd like to use the lib with asyncio and I wonder what would be the recommended way.
I've added a method to NetfilterQueue much like the one for patching with gevent, but I wonder if there are better options for this.
async def run_with_loop(self, loop, sock):
"""Accept packets using loop.sock_recv."""
while True:
try:
buf = await loop.sock_recv(sock, BufferSize)
rv = len(buf)
if rv >= 0:
nfq_handle_packet(self.h, buf, rv)
except socket.error as e:
err = e.args[0]
if err != ENOBUFS:
break