@@ -509,11 +509,18 @@ def main():
|
||||
|
||||
for line in sys.stdin:
|
||||
try:
|
||||
request = json.loads(line.strip())
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
request = json.loads(line)
|
||||
command = request.get("command")
|
||||
data = request.get("data", {})
|
||||
request_id = request.get("requestId", "")
|
||||
|
||||
# Debug logging
|
||||
print(f"DEBUG - Processing command: {command} with ID: {request_id}", file=sys.stderr, flush=True)
|
||||
|
||||
if command:
|
||||
result = dispatch_command(command, **data)
|
||||
response = {
|
||||
@@ -521,6 +528,7 @@ def main():
|
||||
"data": result,
|
||||
"requestId": request_id
|
||||
}
|
||||
print(f"DEBUG - Command {command} completed successfully", file=sys.stderr, flush=True)
|
||||
else:
|
||||
response = {
|
||||
"success": False,
|
||||
@@ -531,6 +539,8 @@ def main():
|
||||
print(json.dumps(response), flush=True)
|
||||
|
||||
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 = {
|
||||
"success": False,
|
||||
"error": str(e),
|
||||
|
||||
@@ -172,8 +172,16 @@ export class PythonBridge extends EventEmitter {
|
||||
const requestId = Math.random().toString(36).substring(2, 15);
|
||||
const request = { command, data, requestId };
|
||||
|
||||
// Set timeout - longer for target operations
|
||||
const timeoutDuration = command === 'set_target' ? 10000 : 30000; // 10s for set_target, 30s for others
|
||||
// Set timeout based on command complexity
|
||||
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(() => {
|
||||
this.requestQueue.delete(requestId);
|
||||
reject(new Error(`Python command timeout: ${command}`));
|
||||
|
||||
Referencia en una nueva incidencia
Block a user