piston
piston copied to clipboard
This Python script crashes Piston (websockets)
#!/bin/python3
import asyncio
import websockets
import json
URL = 'ws://127.0.0.1:2000/api/v2/connect'
SOURCE_CODE = 'echo \\"Hello World!\\"\\nsleep 1\\necho \\"Ok\\"'
JSON_STRING = f'{{ "type": "init", "language": "bash", "version": "*", "files": [{{ "content": "{SOURCE_CODE}" }}]}}'
print(JSON_STRING)
async def run():
async with websockets.connect(URL) as websocket:
await websocket.send(JSON_STRING)
msg = await websocket.recv()
asyncio.run(run())
piston_api | node:internal/errors:415
piston_api | ErrorCaptureStackTrace(err);
piston_api | ^
piston_api |
piston_api | Error: kill ESRCH
piston_api | at process.kill (node:internal/process/per_thread:212:13)
piston_api | at Timeout._onTimeout (/piston_api/src/job.js:171:33)
piston_api | at listOnTimeout (node:internal/timers:557:17)
piston_api | at processTimers (node:internal/timers:500:7) {
piston_api | errno: -3,
piston_api | code: 'ESRCH',
piston_api | syscall: 'kill'
piston_api | }
In the Python script we don't receive further messages from the websocket