Revert "try some shit"

This reverts commit 05c60ca619.
This commit is contained in:
Marks Polakovs 2020-04-12 21:36:09 +02:00
parent 05c60ca619
commit 411527a2b2

View file

@ -15,7 +15,6 @@ from types import TracebackType
import sys import sys
import aiohttp import aiohttp
from raygun4py import raygunprovider # type: ignore from raygun4py import raygunprovider # type: ignore
from concurrent.futures import ProcessPoolExecutor
import configparser import configparser
@ -94,9 +93,6 @@ def process(frames: int) -> None:
buf2[: len(piece2)] = piece2 buf2[: len(piece2)] = piece2
executor = ProcessPoolExecutor(2)
class JackSender(object): class JackSender(object):
resampler: Any resampler: Any
@ -339,7 +335,7 @@ print("Shittyserver WS starting on port {}.".format(config.get("ports", "websock
async def telnet_server( async def telnet_server(
reader: asyncio.StreamReader, writer: asyncio.StreamWriter reader: asyncio.StreamReader, writer: asyncio.StreamWriter
) -> None: ) -> None:
global active_sessions, live_session, executor global active_sessions, live_session
while True: while True:
data = await reader.read(128) data = await reader.read(128)
if not data: if not data:
@ -373,20 +369,18 @@ async def telnet_server(
await live_session.end() await live_session.end()
writer.write("OKAY\r\n".encode("utf-8")) writer.write("OKAY\r\n".encode("utf-8"))
else: else:
writer.write("WONT no_live_session\r\n".encode("utf-8")) writer.write("WONT\r\n".encode("utf-8"))
else: else:
if sid not in active_sessions: if sid not in active_sessions:
writer.write("WONT no_such_session\r\n".encode("utf-8")) writer.write("WONT\r\n".encode("utf-8"))
else: else:
session = active_sessions[sid] session = active_sessions[sid]
if session is None: if session is None:
writer.write("FAIL no_such_session\r\n".encode("utf-8")) writer.write("FAIL\r\n".encode("utf-8"))
elif live_session is not None and live_session.connection_id == sid:
writer.write("WONT already_live\r\n".encode("utf-8"))
else: else:
if live_session is not None: if live_session is not None:
await live_session.end() await live_session.end()
asyncio.create_task(asyncio.get_event_loop().run_in_executor(executor, session.activate)) asyncio.ensure_future(session.activate())
live_session = session live_session = session
writer.write("OKAY\r\n".encode("utf-8")) writer.write("OKAY\r\n".encode("utf-8"))
else: else: