【发布时间】:2021-07-30 00:14:52
【问题描述】:
我有一个运行了几个月的 python Azure 函数。 7/23 开始失败并出现错误线程中没有当前事件循环。
我将发布相关的代码:
在 init.py 我创建一个 JSON 事件,然后调用: '''
run_func(event)
'''
run_func 函数如下所示: '''
def run_func(event):
print("Running Start")
query = "Sites "
client = KustoClient(kcsb)
'''
失败出现在上面显示的最后一行。我已将 azure.kusto.data 包更新到最新版本。它每次都失败并出现相同的错误。
我将在此处发布完整的错误:
2021-07-30T00:00:42.188890984Z ---> Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException:结果:失败 2021-07-30T00:00:42.188893884Z 异常:RuntimeError:线程“ThreadPoolExecutor-0_0”中没有当前事件循环。 2021-07-30T00:00:42.188896584Z 堆栈:文件“/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py”,第 398 行,在 _handle__invocation_request 2021-07-30T00:00:42.188899484Z call_result = await self._loop.run_in_executor( 2021-07-30T00:00:42.188901784Z 文件“/usr/local/lib/python3.8/concurrent/futures/thread.py”,第 57 行,运行中 2021-07-30T00:00:42.188904284Z 结果 = self.fn(*self.args, **self.kwargs) 2021-07-30T00:00:42.188906784Z 文件“/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py”,第 602 行,在 _run_sync_func 2021-07-30T00:00:42.188910284Z 返回 ExtensionManager.get_sync_invocation_wrapper(context, 2021-07-30T00:00:42.188913984Z 文件“/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/extension.py”,第 215 行,在 _raw_invocation_wrapper 2021-07-30T00:00:42.188918084Z 结果 = 函数(**args) 2021-07-30T00:00:42.188921384Z 文件“/home/site/wwwroot/TimerTrigger1/init.py”,第 24 行,主要 2021-07-30T00:00:42.188924985Z run_func(事件) 2021-07-30T00:00:42.188928585Z 文件“/home/site/wwwroot/TimerTrigger1/soofie_azure.py”,第 1281 行,在 run_func 2021-07-30T00:00:42.188931185Z 客户端 = KustoClient(kcsb) 2021-07-30T00:00:42.188944585Z 文件“/home/site/wwwroot/.python_packages/lib/site-packages/azure/kusto/data/client.py”,第 763 行,在 init 2021-07-30T00:00:42.188948785Z self._auth_provider = _AadHelper(self._kcsb) if self._kcsb.aad_federated_security else None 2021-07-30T00:00:42.188953185Z 文件“/home/site/wwwroot/.python_packages/lib/site-packages/azure/kusto/data/security.py”,第 23 行,在 init 2021-07-30T00:00:42.188955785Z self.token_provider = ApplicationKeyTokenProvider(self.kusto_uri, kcsb.authority_id, kcsb.application_client_id, kcsb.application_key) 2021-07-30T00:00:42.188958385Z 文件“/home/site/wwwroot/.python_packages/lib/site-packages/azure/kusto/data/_token_providers.py”,第 485 行,在 init 2021-07-30T00:00:42.188960885Z super().init(kusto_uri) 2021-07-30T00:00:42.188963685Z 文件“/home/site/wwwroot/.python_packages/lib/site-packages/azure/kusto/data/_token_providers.py”,第 69 行,在 init 2021-07-30T00:00:42.188966285Z self._async_lock = asyncio.Lock() 2021-07-30T00:00:42.188968585Z 文件“/usr/local/lib/python3.8/asyncio/locks.py”,第 164 行,在 init 2021-07-30T00:00:42.188971485Z self._loop = events.get_event_loop() 2021-07-30T00:00:42.188974985Z 文件“/usr/local/lib/python3.8/asyncio/events.py”,第 639 行,在 get_event_loop 2021-07-30T00:00:42.188978885Z raise RuntimeError('There is no current event loop in thread %r.'
【问题讨论】:
标签: python azure azure-functions azure-data-explorer