Implement modules.

This commit is contained in:
Sarah 2021-10-17 12:01:40 +02:00
parent 6be67a1916
commit 1c7138e499
No known key found for this signature in database
GPG key ID: 708F7ACE058F0186
6 changed files with 164 additions and 15 deletions

View file

@ -6,8 +6,12 @@ from hypercorn.asyncio import serve
from peerix.app import app
if __name__ == "__main__":
def run():
uvloop.install()
config = Config()
config.bind = ["0.0.0.0:12304"]
asyncio.run(serve(app, config))
if __name__ == "__main__":
run()

View file

@ -104,7 +104,9 @@ class DiscoveryProtocol(asyncio.DatagramProtocol, Store):
self.transport.sendto(b"".join([b"\x00", idx.to_bytes(4, "big"), hsh.encode("utf-8")]), (addr, self.local_port))
try:
port, url, addr = await asyncio.wait_for(fut, 0.5)
# This must have a short timeout so it does not noticably slow down
# querying of other caches.
port, url, addr = await asyncio.wait_for(fut, 0.05)
except asyncio.TimeoutError:
print(f"No response for {hsh}")
return None