GetSessionStatus

get_session_status(public_api_client, session_id)
Expand source code
get_session_status(public_api_client, session_id):
"""
Description
-----------
To get the status of a given session.
Args
----
public_api_client: QDC api client object.
session_id: Id of the session.
Returns
-------
string: State of the session. like completed, canceled etc.
None: In case of any failure.
Usages
------
session_id = "1234"
poll_session_status = qdc_api.get_session_status(public_api_client, session_id)
if poll_session_status.lower() == "completed":
print("Session is completed, exiting client...")
break
elif poll_session_status.lower() == "canceled":
print("Session is canceled, exiting client...")
break
else:
print(f"Session is in {poll_session_status.lower()} mode)
"""
poll_session_response = get_sessions_session_id.sync_detailed(session_id=session_id, client=_get_client_with_new_trace_header(public_api_client))
if poll_session_response.status_code == 200:
response_data = poll_session_response.content.decode('utf-8')
print(f"Session response: {response_data}")
return poll_session_response.parsed.state
Description
To get the status of a given session.
Arguments
public_api_client: QDC api client object.
session_id: Id of the session.
Returns
string: State of the session. like completed, canceled etc.
None: In case of any failure.
Usages
session_id = "1234"
poll_session_status = qdc_api.get_session_status(public_api_client, session_id)
if poll_session_status.lower() == "completed":
print("Session is completed, exiting client...")
break
elif poll_session_status.lower() == "canceled":
print("Session is canceled, exiting client...")
break
else:
print(f"Session is in {poll_session_status.lower()} mode)