@@ -509,11 +509,18 @@ def main():
|
|||||||
|
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
try:
|
try:
|
||||||
request = json.loads(line.strip())
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
request = json.loads(line)
|
||||||
command = request.get("command")
|
command = request.get("command")
|
||||||
data = request.get("data", {})
|
data = request.get("data", {})
|
||||||
request_id = request.get("requestId", "")
|
request_id = request.get("requestId", "")
|
||||||
|
|
||||||
|
# Debug logging
|
||||||
|
print(f"DEBUG - Processing command: {command} with ID: {request_id}", file=sys.stderr, flush=True)
|
||||||
|
|
||||||
if command:
|
if command:
|
||||||
result = dispatch_command(command, **data)
|
result = dispatch_command(command, **data)
|
||||||
response = {
|
response = {
|
||||||
@@ -521,6 +528,7 @@ def main():
|
|||||||
"data": result,
|
"data": result,
|
||||||
"requestId": request_id
|
"requestId": request_id
|
||||||
}
|
}
|
||||||
|
print(f"DEBUG - Command {command} completed successfully", file=sys.stderr, flush=True)
|
||||||
else:
|
else:
|
||||||
response = {
|
response = {
|
||||||
"success": False,
|
"success": False,
|
||||||
@@ -531,6 +539,8 @@ def main():
|
|||||||
print(json.dumps(response), flush=True)
|
print(json.dumps(response), flush=True)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f"ERROR - Exception in main loop: {str(e)}", file=sys.stderr, flush=True)
|
||||||
|
print(f"ERROR - Traceback: {traceback.format_exc()}", file=sys.stderr, flush=True)
|
||||||
error_response = {
|
error_response = {
|
||||||
"success": False,
|
"success": False,
|
||||||
"error": str(e),
|
"error": str(e),
|
||||||
|
|||||||
@@ -172,8 +172,16 @@ export class PythonBridge extends EventEmitter {
|
|||||||
const requestId = Math.random().toString(36).substring(2, 15);
|
const requestId = Math.random().toString(36).substring(2, 15);
|
||||||
const request = { command, data, requestId };
|
const request = { command, data, requestId };
|
||||||
|
|
||||||
// Set timeout - longer for target operations
|
// Set timeout based on command complexity
|
||||||
const timeoutDuration = command === 'set_target' ? 10000 : 30000; // 10s for set_target, 30s for others
|
let timeoutDuration = 5000; // Default 5s
|
||||||
|
|
||||||
|
if (command === 'set_target') {
|
||||||
|
timeoutDuration = 10000; // 10s for target operations
|
||||||
|
} else if (['sample', 'observe', 'get_state'].includes(command)) {
|
||||||
|
timeoutDuration = 15000; // 15s for quantum operations
|
||||||
|
} else if (['get_platform_info', 'get_available_targets', 'list_kernels'].includes(command)) {
|
||||||
|
timeoutDuration = 3000; // 3s for simple info operations
|
||||||
|
}
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
this.requestQueue.delete(requestId);
|
this.requestQueue.delete(requestId);
|
||||||
reject(new Error(`Python command timeout: ${command}`));
|
reject(new Error(`Python command timeout: ${command}`));
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user