summaryrefslogtreecommitdiffstats
path: root/tests/servers/invalid_json.py
blob: 5b40d7a697048c35f8eae083cd4c56b678922ccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""This server does nothing but print invalid JSON."""
import asyncio
import threading
import sys
from concurrent.futures import ThreadPoolExecutor

from pygls.server import aio_readline


def handler(data):
    content = 'Content-Length: 5\r\n\r\n{"ll}'.encode("utf8")
    sys.stdout.buffer.write(content)
    sys.stdout.flush()


async def main():
    await aio_readline(
        asyncio.get_running_loop(),
        ThreadPoolExecutor(),
        threading.Event(),
        sys.stdin.buffer,
        handler,
    )


if __name__ == "__main__":
    asyncio.run(main())