athena.getQueryExecution在1分钟以上返回一个正在运行的状态,尽管查询历史显示作业只花费了4秒钟。
创始人
2024-09-21 13:00:22
0

要解决athena.getQueryExecution在1分钟以上返回一个正在运行的状态,尽管查询历史显示作业只花费了4秒钟的问题,可以尝试以下方法:

  1. 确保使用的是正确的查询ID。可以通过运行athena.startQueryExecution方法获取最新的查询ID,并将其传递给athena.getQueryExecution。
import boto3
import time

athena = boto3.client('athena')
query_execution_id = "YOUR_QUERY_EXECUTION_ID"

response = athena.get_query_execution(QueryExecutionId=query_execution_id)
status = response['QueryExecution']['Status']['State']

start_time = time.time()

while status in ['QUEUED', 'RUNNING']:
    response = athena.get_query_execution(QueryExecutionId=query_execution_id)
    status = response['QueryExecution']['Status']['State']
    
    elapsed_time = time.time() - start_time
    
    if elapsed_time > 60:
        break
    
    time.sleep(1)

if status == 'SUCCEEDED':
    print("Query completed successfully!")
else:
    print("Query did not complete within 1 minute.")
  1. 确保查询已经完成。有时候,Athena可能会在查询执行完成后的几秒钟内返回一个正在运行的状态。可以在获取查询状态后,再次调用get_query_execution方法来确认查询是否已经完成。
import boto3
import time

athena = boto3.client('athena')
query_execution_id = "YOUR_QUERY_EXECUTION_ID"

response = athena.get_query_execution(QueryExecutionId=query_execution_id)
status = response['QueryExecution']['Status']['State']

start_time = time.time()

while status in ['QUEUED', 'RUNNING']:
    response = athena.get_query_execution(QueryExecutionId=query_execution_id)
    status = response['QueryExecution']['Status']['State']
    
    elapsed_time = time.time() - start_time
    
    if elapsed_time > 60:
        break
    
    time.sleep(1)

# 确保查询已经完成
response = athena.get_query_execution(QueryExecutionId=query_execution_id)
status = response['QueryExecution']['Status']['State']

if status == 'SUCCEEDED':
    print("Query completed successfully!")
else:
    print("Query did not complete within 1 minute.")

通过以上方法,你可以确保在1分钟内获取到正确的查询状态,以便进一步处理查询结果。需要注意的是,上述示例中的"YOUR_QUERY_EXECUTION_ID"需要替换为实际的查询ID。

相关内容

热门资讯

wepoke辅助挂!德扑之星系... wepoke辅助挂!德扑之星系统有哪里规律,微扑克ai机器人,安装教程(有挂详情)(1)wepoke...
wpk透视辅助工具!wpk发牌... wpk透视辅助工具!wpk发牌规律,菠萝德州app挂哪里买,黑科技教程(有挂教程)是一款可以让一直输...
wepower有外挂!wopo... wepower有外挂!wopoker系统套路,来玩app有挂,透明教程(有挂教学)1)wepower...
aapoker猫腻!好运大菠萝... aapoker猫腻!好运大菠萝有辅助吗,wepoke辅助真的,AA德州教程(有挂了解)是一款可以让一...
德州之星有辅助挂!wpk数据手... 德州之星有辅助挂!wpk数据手机软件叫啥,德州wepower透视辅助,详细教程(有挂详情)您好,德州...
wepoke辅助挂!aapok... wepoke辅助挂!aapoke辅助工具存在吗,微扑克有挂,可靠教程(有挂详情)1、超多福利:超高返...
微扑克辅助挂!微扑克有挂,wp... 一、微扑克辅助挂简介了解软件请加微:136704302微扑克辅助挂是一款在线扑克游戏平台,玩家可以在...
wpk俱乐部!德州线上扑克辅助... wpk俱乐部!德州线上扑克辅助工具app,德扑牌型胜率,技巧教程(有挂方法)1、在wpk俱乐部ai机...
aapoker透视辅助!微扑克... aapoker透视辅助!微扑克辅助机器人,德州ai能盈利,教你攻略(有挂攻略);人气非常高,ai更新...
wpk透视辅助工具!gg扑克发... wpk透视辅助工具!gg扑克发牌问题,wepoke软件透明挂,wpk教程(有挂技巧)是一款可以让一直...