mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
* fix up folder structure * update docs * fix imports * fix imports * fix imoprt * fix imports * fix imports * fix imports * fix test import * fix tests * fix main import
27 lines
627 B
Python
27 lines
627 B
Python
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
import requests
|
|
|
|
# Read the Python code from STDIN
|
|
code = sys.stdin.read()
|
|
|
|
# Set the default kernel ID
|
|
kernel_id = 'default'
|
|
|
|
# try 5 times until success
|
|
PORT = os.environ.get('JUPYTER_EXEC_SERVER_PORT')
|
|
POST_URL = f'http://localhost:{PORT}/execute'
|
|
|
|
for i in range(5):
|
|
response = requests.post(POST_URL, json={'kernel_id': kernel_id, 'code': code})
|
|
# if "500: Internal Server Error" is not in the response, break the loop
|
|
if '500: Internal Server Error' not in response.text:
|
|
break
|
|
time.sleep(1)
|
|
|
|
# Print the response
|
|
print(str(response.text))
|