Commit f16a062d authored by eckhart's avatar eckhart
Browse files

- stub for a compilation-server-module extended

parent 9bf2aea1
......@@ -53,44 +53,26 @@ class CompilerServer:
self.compiler = compiler
self.max_source_size = get_config_value('max_source_size')
def handle_compilation_request(self, reader, writer):
async def handle_compilation_request(self,
reader: asyncio.StreamReader,
writer: asyncio.StreamWriter):
data = await + 1)
if len(data) > self.max_source_size:
"Source code to large! Only %iMB allowed." %
(self.max_source_size // (1024**2)) + END_TOKEN)
pass # TODO: to be continued
writer.write(data) # for now, only echo
await writer.drain()
async def handle_echo(reader, writer):
# TODO: Add deliver/answer-challenge-mechanism here to verify the source
# see file:///usr/share/doc/python/html/library/multiprocessing.html?highlight=connection#module-multiprocessing.connection
data = await
message = data.decode()
addr = writer.get_extra_info('peername')
async def _compiler_server(self, address: str, port: int):
server = await syncio.start_server(self.handle_compilation_request, address, port)
async with server:
await server.serve_forever
print(f"Received {message!r} from {addr!r}")
def serve(self, address: str='', port: int=8888):
# TODO: Replace this by a python 3.5. compatible construct...
await asyncio.sleep(5)
print(f"Send: {message!r}")
await writer.drain()
print("Close the connection")
async def main():
server = await asyncio.start_server(
handle_echo, '', 8888)
addr = server.sockets[0].getsockname()
print(f'Serving on {addr}')
async with server:
await server.serve_forever()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment