style: some comments
This commit is contained in:
parent
94fa1987d3
commit
6c886e0fa7
|
@ -41,7 +41,7 @@ core.reset()
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(name)s %(levelname)-8s %(message)s", datefmt="(%F %T)")
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(name)s %(levelname)-8s %(message)s", datefmt="(%F %T)")
|
||||||
|
|
||||||
# disable all loggers from different files
|
# change log levels for some libs
|
||||||
logging.getLogger("asyncio").setLevel(logging.ERROR)
|
logging.getLogger("asyncio").setLevel(logging.ERROR)
|
||||||
logging.getLogger("asyncio.coroutines").setLevel(logging.ERROR)
|
logging.getLogger("asyncio.coroutines").setLevel(logging.ERROR)
|
||||||
mgba.log.silence()
|
mgba.log.silence()
|
||||||
|
@ -49,7 +49,7 @@ mgba.log.silence()
|
||||||
r: redis.Redis = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, db=0)
|
r: redis.Redis = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, db=0)
|
||||||
|
|
||||||
|
|
||||||
# Launch ffmpeg process
|
# launch ffmpeg process
|
||||||
stream = Popen(
|
stream = Popen(
|
||||||
[
|
[
|
||||||
"/usr/bin/ffmpeg",
|
"/usr/bin/ffmpeg",
|
||||||
|
|
|
@ -23,7 +23,7 @@ from utils import User, Users
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(name)s %(levelname)-8s %(message)s", datefmt="(%F %T)")
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(name)s %(levelname)-8s %(message)s", datefmt="(%F %T)")
|
||||||
|
|
||||||
# disable all loggers from different files
|
# change log levels for some libs
|
||||||
logging.getLogger("asyncio").setLevel(logging.ERROR)
|
logging.getLogger("asyncio").setLevel(logging.ERROR)
|
||||||
logging.getLogger("asyncio.coroutines").setLevel(logging.ERROR)
|
logging.getLogger("asyncio.coroutines").setLevel(logging.ERROR)
|
||||||
logging.getLogger("websockets.server").setLevel(logging.ERROR)
|
logging.getLogger("websockets.server").setLevel(logging.ERROR)
|
||||||
|
@ -60,11 +60,11 @@ async def handler(websocket: websockets.server.WebSocketServerProtocol, path: st
|
||||||
websocket: the websocket used by the user.
|
websocket: the websocket used by the user.
|
||||||
path (str): the path used by the websocket.
|
path (str): the path used by the websocket.
|
||||||
"""
|
"""
|
||||||
# Register user
|
# register user
|
||||||
user = User(websocket)
|
user = User(websocket)
|
||||||
USERS.register(user)
|
USERS.register(user)
|
||||||
|
|
||||||
try: # Manage received messages
|
try: # manage received messages
|
||||||
async for message in user.websocket:
|
async for message in user.websocket:
|
||||||
await parse_message(user, message)
|
await parse_message(user, message)
|
||||||
except websockets.exceptions.ConnectionClosed:
|
except websockets.exceptions.ConnectionClosed:
|
||||||
|
@ -72,7 +72,7 @@ async def handler(websocket: websockets.server.WebSocketServerProtocol, path: st
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
logging.error(f"two coroutines called recv() concurrently, user={user}")
|
logging.error(f"two coroutines called recv() concurrently, user={user}")
|
||||||
finally:
|
finally:
|
||||||
USERS.unregister(user)
|
USERS.unregister(user) # unregister user
|
||||||
|
|
||||||
|
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
|
|
Loading…
Reference in a new issue