File: invalid_json.py

package info (click to toggle)
pygls 1.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,588 kB
  • sloc: python: 9,820; javascript: 28; makefile: 11
file content (27 lines) | stat: -rw-r--r-- 569 bytes parent folder | download | duplicates (3)
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())