MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / _submit_queue_request

Function _submit_queue_request

keepercommander/service/api/command.py:44–76  ·  view source on GitHub ↗

Submit a request to the queue, optionally waiting for the result.

(processed_command: str, temp_files: list, wait_for_completion: bool)

Source from the content-addressed store, hash-verified

42
43
44def _submit_queue_request(processed_command: str, temp_files: list, wait_for_completion: bool):
45 """Submit a request to the queue, optionally waiting for the result."""
46 request_submitted = False
47 owner_key = _caller_owner_key()
48 try:
49 request_id = queue_manager.submit_request(
50 processed_command, temp_files, owner_key=owner_key
51 )
52 request_submitted = True
53 except queue.Full:
54 RequestValidator.cleanup_temp_files(temp_files)
55 return (jsonify({
56 "status": "error",
57 "error": "Error: Request queue is full. Please try again later."
58 }), 503), False
59
60 if wait_for_completion:
61 result_data = queue_manager.wait_for_result(request_id, owner_key=owner_key)
62 if result_data is None:
63 return (jsonify({
64 "status": "error",
65 "error": "Error: Request not found after submission"
66 }), 500), request_submitted
67
68 response, status_code = result_data
69 return (response if isinstance(response, bytes) else jsonify(response), status_code), request_submitted
70
71 return (jsonify({
72 "success": True,
73 "request_id": request_id,
74 "status": "queued",
75 "message": "Request queued successfully. Use /api/v2/status/<request_id> to check progress, /api/v2/result/<request_id> to get results, or /api/v2/queue/status for queue info."
76 }), 202), request_submitted
77
78
79def create_legacy_command_blueprint(use_queue: bool = False):

Callers 2

execute_command_directFunction · 0.85
execute_commandFunction · 0.85

Calls 4

_caller_owner_keyFunction · 0.85
submit_requestMethod · 0.80
cleanup_temp_filesMethod · 0.80
wait_for_resultMethod · 0.80

Tested by

no test coverage detected