Browse Source

linting

main
Michael Pilosov 2 years ago
parent
commit
fe15bbbf1e
  1. 19
      src/announce_server/client.py
  2. 4
      src/announce_server/server.py

19
src/announce_server/client.py

@ -1,12 +1,13 @@
import asyncio
import argparse
import asyncio
import signal
import threading
from http.server import HTTPServer, SimpleHTTPRequestHandler
import socketio
from .decorator import register_service
from .get_ip import get_ip_address
import socketio
sio = socketio.AsyncClient()
@ -99,10 +100,17 @@ def exit_handler(sig, frame):
# except (KeyboardInterrupt, asyncio.exceptions.CancelledError):
# print("Cleaning up and shutting down...")
def start_client(host_ip="0.0.0.0", host_port=4999):
@register_service(name="test client", ip=get_ip_address(), port=13373, host_ip=host_ip, host_port=host_port)
@register_service(
name="test client",
ip=get_ip_address(),
port=13373,
host_ip=host_ip,
host_port=host_port,
)
def server(port=13373):
httpd = HTTPServer(('', port), SimpleHTTPRequestHandler)
httpd = HTTPServer(("", port), SimpleHTTPRequestHandler)
print(f"Serving HTTP on 0.0.0.0 port {port} (http://0.0.0.0:{port}/) ...")
def serve_forever_nonblocking():
@ -121,7 +129,6 @@ def start_client(host_ip="0.0.0.0", host_port=4999):
signal.signal(signal.SIGINT, exit_handler)
signal.signal(signal.SIGTERM, exit_handler)
try:
server_thread = server()
asyncio.run(main(host_ip, host_port))

4
src/announce_server/server.py

@ -167,9 +167,7 @@ def start_server(address, port, heartbeat_interval, heartbeat_timeout):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Start announce_server client.")
parser.add_argument(
"--ip", default="0.0.0.0", help="IP address of the host server"
)
parser.add_argument("--ip", default="0.0.0.0", help="IP address of the host server")
parser.add_argument(
"--port", default=4999, type=int, help="Port of the host server"
)

Loading…
Cancel
Save