This method polls the result of the asynchronous query and returns the result. Args: trans_id: unique transaction id
(trans_id)
| 1067 | @blueprint.route('/poll/<int:trans_id>', methods=["GET"], endpoint='poll') |
| 1068 | @pga_login_required |
| 1069 | def poll(trans_id): |
| 1070 | """ |
| 1071 | This method polls the result of the asynchronous query and returns |
| 1072 | the result. |
| 1073 | |
| 1074 | Args: |
| 1075 | trans_id: unique transaction id |
| 1076 | """ |
| 1077 | result = None |
| 1078 | rows_affected = 0 |
| 1079 | rows_fetched_from = 0 |
| 1080 | rows_fetched_to = 0 |
| 1081 | columns = dict() |
| 1082 | columns_info = None |
| 1083 | primary_keys = None |
| 1084 | types = {} |
| 1085 | client_primary_key = None |
| 1086 | has_oids = False |
| 1087 | oids = None |
| 1088 | additional_messages = None |
| 1089 | notifies = None |
| 1090 | data_obj = {} |
| 1091 | data_result_rows_per_page = Preferences.module(MODULE_NAME).\ |
| 1092 | preference('data_result_rows_per_page').get() |
| 1093 | # Check the transaction and connection status |
| 1094 | status, error_msg, conn, trans_obj, session_obj = \ |
| 1095 | check_transaction_status(trans_id) |
| 1096 | |
| 1097 | if type(error_msg) is Response: |
| 1098 | return error_msg |
| 1099 | |
| 1100 | if error_msg == ERROR_MSG_TRANS_ID_NOT_FOUND: |
| 1101 | return make_json_response(success=0, errormsg=error_msg, |
| 1102 | info='DATAGRID_TRANSACTION_REQUIRED', |
| 1103 | status=404) |
| 1104 | |
| 1105 | is_thread_alive = False |
| 1106 | if trans_obj.get_thread_native_id(): |
| 1107 | for thread in threading.enumerate(): |
| 1108 | _native_id = thread.native_id if hasattr(thread, 'native_id' |
| 1109 | ) else thread.ident |
| 1110 | if _native_id == trans_obj.get_thread_native_id() and\ |
| 1111 | thread.is_alive(): |
| 1112 | is_thread_alive = True |
| 1113 | break |
| 1114 | |
| 1115 | # if transaction object is instance of QueryToolCommand |
| 1116 | # and transaction aborted for some reason then issue a |
| 1117 | # rollback to cleanup |
| 1118 | if isinstance(trans_obj, QueryToolCommand): |
| 1119 | trans_status = conn.transaction_status() |
| 1120 | if trans_status == TX_STATUS_INERROR and trans_obj.auto_rollback: |
| 1121 | conn.execute_void("ROLLBACK;") |
| 1122 | |
| 1123 | if is_thread_alive: |
| 1124 | status = 'Busy' |
| 1125 | messages = conn.messages() |
| 1126 | if messages and len(messages) > 0: |
nothing calls this directly
no test coverage detected