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

Function _submit_queue_request

keepercommander/service/api/command.py:40–72  ·  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

38
39
40def _submit_queue_request(processed_command: str, temp_files: list, wait_for_completion: bool):
41 """Submit a request to the queue, optionally waiting for the result."""
42 request_submitted = False
43 owner_key = _caller_owner_key()
44 try:
45 request_id = queue_manager.submit_request(
46 processed_command, temp_files, owner_key=owner_key
47 )
48 request_submitted = True
49 except queue.Full:
50 RequestValidator.cleanup_temp_files(temp_files)
51 return (jsonify({
52 "status": "error",
53 "error": "Error: Request queue is full. Please try again later."
54 }), 503), False
55
56 if wait_for_completion:
57 result_data = queue_manager.wait_for_result(request_id, owner_key=owner_key)
58 if result_data is None:
59 return (jsonify({
60 "status": "error",
61 "error": "Error: Request not found after submission"
62 }), 500), request_submitted
63
64 response, status_code = result_data
65 return (response if isinstance(response, bytes) else jsonify(response), status_code), request_submitted
66
67 return (jsonify({
68 "success": True,
69 "request_id": request_id,
70 "status": "queued",
71 "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."
72 }), 202), request_submitted
73
74
75def 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