- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个带有计时器触发器的 Python Azure 函数。为了按需进行本地测试,我将 RunOnStartup 选项设置为 True ( Microsoft documentation here )。
我的简化 Python 代码如下所示:
import logging
import azure.functions as func
import sendgrid
from sendgrid import SendGridAPIClient
import azure.storage.blob
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
import wikipedia
import json, os
from datetime import datetime
//Initializations
def main(mytimer: func.TimerRequest, inputblob: func.InputStream) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
// Do stuff
我的 function.json(带有计时器触发器和 blob 输入绑定(bind)):
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 30 9 * * *",
"runOnStartup": true
},
{
"name": "inputblob",
"type": "blob",
"path": "sharefiles/versionIds.json",
"connection": "shareFilesConnString",
"direction": "in"
}
]
}
还有我的hosts.json:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
但是,在我的计算机上本地运行该函数进行测试时,我得到以下输出。最明显的错误是:
System.Private.CoreLib: Exception while executing function: Functions.. Microsoft.Azure.WebJobs.Script: Did not find any initialized language workers.
Executing task: .venv\Scripts\activate ; func host start <
Found Python version 3.7.5 (python).
%%%%%%
%%%%%%
@ %%%%%% @
@@ %%%%%% @@
@@@ %%%%%%%%%%% @@@
@@ %%%%%%%%%% @@
@@ %%%% @@
@@ %%% @@
@@ %% @@
%%
%
Azure Functions Core Tools (2.7.1948 Commit hash: 29a0626ded3ae99c4111f66763f27bb9fb564103)
Function Runtime Version: 2.0.12888.0
[12/10/2019 8:11:29 PM] File 'C:\Program Files\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[12/10/2019 8:11:29 PM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'ca4aefed-0190-45d6-9ad6-d22c0cd6abf1'
[12/10/2019 8:11:29 PM] Reading host configuration file 'C:\Users\<redacted>\Desktop\TimerTrigger\host.json'
[12/10/2019 8:11:29 PM] Host configuration file read:
[12/10/2019 8:11:29 PM] {
[12/10/2019 8:11:29 PM] "version": "2.0",
[12/10/2019 8:11:29 PM] "extensionBundle": {
[12/10/2019 8:11:29 PM] "id": "Microsoft.Azure.Functions.ExtensionBundle",
[12/10/2019 8:11:29 PM] "version": "[1.*, 2.0.0)"
[12/10/2019 8:11:29 PM] }
[12/10/2019 8:11:29 PM] }
[12/10/2019 8:11:29 PM] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle
at C:\Users\<redacted>\AppData\Local\Temp\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle
[12/10/2019 8:11:29 PM] Found a matching extension bundle at C:\Users\<redacted>\AppData\Local\Temp\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle\1.1.1
[12/10/2019 8:11:29 PM] Fetching information on versions of extension bundle Microsoft.Azure.Functions.ExtensionBundle available on https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/index.json
[12/10/2019 8:11:29 PM] Skipping bundle download since it already exists at path C:\Users\<redacted>\AppData\Local\Temp\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle\1.1.1
[12/10/2019 8:11:29 PM] Loading Extention bundle from C:\Users\<redacted>\AppData\Local\Temp\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle\1.1.1
[12/10/2019 8:11:29 PM] Reading functions metadata
[12/10/2019 8:11:29 PM] 1 functions found
[12/10/2019 8:11:29 PM] Loading startup extension 'AzureStorage'
[12/10/2019 8:11:29 PM] Loaded extension 'AzureStorage' (3.0.10.0)
[12/10/2019 8:11:30 PM] File 'C:\Program Files\dotnet\dotnet.exe' is not found, 'dotnet' invocation will rely on the PATH environment variable.
[12/10/2019 8:11:30 PM] Initializing Warmup Extension.
[12/10/2019 8:11:30 PM] Initializing Host. OperationId: 'ca4aefed-0190-45d6-9ad6-d22c0cd6abf1'.[12/10/2019 8:11:30 PM] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=ca4aefed-0190-45d6-9ad6-d22c0cd6abf1
[12/10/2019 8:11:30 PM] LoggerFilterOptions
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "MinLevel": "None",
[12/10/2019 8:11:30 PM] "Rules": [
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "ProviderName": null,
[12/10/2019 8:11:30 PM] "CategoryName": null,
[12/10/2019 8:11:30 PM] "LogLevel": null,
[12/10/2019 8:11:30 PM] "Filter": "<AddFilter>b__0"
[12/10/2019 8:11:30 PM] },
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[12/10/2019 8:11:30 PM] "CategoryName": null,
[12/10/2019 8:11:30 PM] "LogLevel": "None",
[12/10/2019 8:11:30 PM] "Filter": null
[12/10/2019 8:11:30 PM] },
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[12/10/2019 8:11:30 PM] "CategoryName": null,
[12/10/2019 8:11:30 PM] "LogLevel": null,
[12/10/2019 8:11:30 PM] "Filter": "<AddFilter>b__0"
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] ]
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] FunctionResultAggregatorOptions
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "BatchSize": 1000,
[12/10/2019 8:11:30 PM] "FlushTimeout": "00:00:30",
[12/10/2019 8:11:30 PM] "IsEnabled": true
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] SingletonOptions
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "LockPeriod": "00:00:15",
[12/10/2019 8:11:30 PM] "ListenerLockPeriod": "00:00:15",
[12/10/2019 8:11:30 PM] "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[12/10/2019 8:11:30 PM] "LockAcquisitionPollingInterval": "00:00:05",
[12/10/2019 8:11:30 PM] "ListenerLockRecoveryPollingInterval": "00:01:00"
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] QueuesOptions
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "BatchSize": 16,
[12/10/2019 8:11:30 PM] "NewBatchThreshold": 8,
[12/10/2019 8:11:30 PM] "MaxPollingInterval": "00:00:02",
[12/10/2019 8:11:30 PM] "MaxDequeueCount": 5,
[12/10/2019 8:11:30 PM] "VisibilityTimeout": "00:00:00"
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] BlobsOptions
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "CentralizedPoisonQueue": false
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] HttpOptions
[12/10/2019 8:11:30 PM] {
[12/10/2019 8:11:30 PM] "DynamicThrottlesEnabled": false,
[12/10/2019 8:11:30 PM] "MaxConcurrentRequests": -1,
[12/10/2019 8:11:30 PM] "MaxOutstandingRequests": -1,
[12/10/2019 8:11:30 PM] "RoutePrefix": "api"
[12/10/2019 8:11:30 PM] }
[12/10/2019 8:11:30 PM] Starting JobHost
[12/10/2019 8:11:30 PM] Starting Host (HostId=desktopl8i1u40-13243865, InstanceId=49bcc245-e949-45fd-b731-1e5ccd7ebbdc, Version=2.0.12888.0, ProcessId=10432, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=~2)
[12/10/2019 8:11:30 PM] Loading functions metadata
[12/10/2019 8:11:30 PM] 1 functions loaded
[12/10/2019 8:11:30 PM] Loading proxies metadata
[12/10/2019 8:11:30 PM] Initializing Azure Function proxies
[12/10/2019 8:11:30 PM] 0 proxies loaded
[12/10/2019 8:11:30 PM] Starting worker process:python c:/Users/<redacted>/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/ptvsd_launcher.py --default --host 127.0.0.1 --port 9091 --wait "C:\Users\<redacted>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 55800 --workerId 0edae10c-af7f-4e37-8d13-382365306813 --requestId d0d3851a-1ee8-411d-bb74-426ab04b44b6 --grpcMaxMessageLength 134217728
[12/10/2019 8:11:30 PM] python process with Id=13188 started
[12/10/2019 8:11:30 PM] Generating 1 job function(s)
[12/10/2019 8:11:31 PM] Found the following functions:
[12/10/2019 8:11:31 PM] Host.Functions.<functionname>
[12/10/2019 8:11:31 PM]
[12/10/2019 8:11:31 PM] Initializing function HTTP routes
[12/10/2019 8:11:31 PM] No HTTP routes mapped
[12/10/2019 8:11:31 PM]
[12/10/2019 8:11:31 PM] Host initialized (546ms)
[12/10/2019 8:11:31 PM] Executing 'Functions.<functionname>' (Reason='Timer fired at 2019-12-10T15:11:31.5531175-05:00', Id=6176e5d6-c860-4bf7-80e5-712b8919310d)
[12/10/2019 8:11:31 PM] Trigger Details: UnscheduledInvocationReason: RunOnStartup
[12/10/2019 8:12:30 PM] Starting worker process failed
[12/10/2019 8:12:30 PM] The operation has timed out.
[12/10/2019 8:12:31 PM] Starting worker process:python c:/Users/<redacted>/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/ptvsd_launcher.py --default --host 127.0.0.1 --port 9091 --wait "C:\Users\<redacted>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 55800 --workerId d68b30e0-3146-43f7-92bf-5a8f57ebf3a1 --requestId a4e0053f-b28d-44e1-9671-ac1431349d8e --grpcMaxMessageLength 134217728
[12/10/2019 8:12:31 PM] python process with Id=1524 started
[12/10/2019 8:12:31 PM] Executed 'Functions.<functionname>' (Failed, Id=6176e5d6-c860-4bf7-80e5-712b8919310d)
[12/10/2019 8:12:31 PM] System.Private.CoreLib: Exception while executing function: Functions.<functionname>. Microsoft.Azure.WebJobs.Script: Did not find any initialized language workers.
[12/10/2019 8:12:31 PM] The next 5 occurrences of the '<functionname>' schedule (Cron: '0 30 9 * * *') will be:
[12/10/2019 8:12:31 PM] 12/11/2019 09:30:00-05:00 (12/11/2019 14:30:00Z)
[12/10/2019 8:12:31 PM] 12/12/2019 09:30:00-05:00 (12/12/2019 14:30:00Z)
[12/10/2019 8:12:31 PM] 12/13/2019 09:30:00-05:00 (12/13/2019 14:30:00Z)
[12/10/2019 8:12:31 PM] 12/14/2019 09:30:00-05:00 (12/14/2019 14:30:00Z)
[12/10/2019 8:12:31 PM] 12/15/2019 09:30:00-05:00 (12/15/2019 14:30:00Z)
[12/10/2019 8:12:31 PM]
[12/10/2019 8:12:31 PM] Host started (61122ms)
[12/10/2019 8:12:31 PM] Job host started
Hosting environment: Production
Content root path: C:\Users\<redacted>\Desktop\TimerTrigger
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[12/10/2019 8:12:36 PM] Host lock lease acquired by instance ID '00000000000000000000000086626BD5'.
[12/10/2019 8:12:37 PM] INFO: Starting Azure Functions Python Worker.
[12/10/2019 8:12:37 PM] INFO: Worker ID: d68b30e0-3146-43f7-92bf-5a8f57ebf3a1, Request ID: a4e0053f-b28d-44e1-9671-ac1431349d8e, Host Address: 127.0.0.1:55800
[12/10/2019 8:12:37 PM] INFO: Successfully opened gRPC channel to 127.0.0.1:55800
[12/10/2019 8:12:37 PM] INFO: Received WorkerInitRequest, request ID a4e0053f-b28d-44e1-9671-ac1431349d8e
[12/10/2019 8:12:37 PM] INFO: Received FunctionLoadRequest, request ID: a4e0053f-b28d-44e1-9671-ac1431349d8e, function ID: 1cf61de1-d4a3-4011-8695-98d4a973f1a9
[12/10/2019 8:12:37 PM] INFO: Successfully processed FunctionLoadRequest, request ID: a4e0053f-b28d-44e1-9671-ac1431349d8e, function ID: 1cf61de1-d4a3-4011-8695-98d4a973f1a9
我错过了什么?
最佳答案
更新:
已重现您的错误。
首先请检查C:\Program Files\dotnet
下是否有dotnet.exe
其次,请检查您的环境变量。
第三,更改settings.json。
{
"azureFunctions.deploySubpath": ".",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~2",
"debug.internalConsoleOptions": "neverOpen",
"python.pythonPath": ".venv\\Scripts\\python.exe"
}
上图是我的settings.json。如果我没看错的话,我使用了与您相同的设置。
请像这样更改settings.json:
{
"azureFunctions.deploySubpath": ".",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~2",
"debug.internalConsoleOptions": "neverOpen",
"python.pythonPath": "/path/to/your/venv/bin/python"
}
最终函数可以成功运行并触发。
原始答案:
尝试找到settings.json
文件,
然后你可以像这样找到你的文件:
{
"python.pythonPath": "xxxxxxxxx",
...
}
更改为
{
"python.pythonPath": "/path/to/your/venv/bin/python",
...
}
我以前遇到过这个错误,但使用此设置功能可以正常工作。
关于python - Python 中具有计时器触发器和 RunOnStartup 的 Azure 函数在本地失败,并出现错误 "Did not find any initialized language workers",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59274944/
我需要在 文档就绪 触发后 5 秒调用我的函数 abc()。 这在 jQuery 中可能吗? $(document).ready(function () { //Wait 5 seconds then
我发现 System.Diagnostics.Stopwatch 类即使在很短的时间段(即 20 秒)内似乎也存在可测量的不准确性。对于编码为运行 20 秒的进程,我的进程显示耗时为 20.3+ 秒:
我正在使用 Ionic Framework 使用 Angular 构建一个 Android/iPhone 食谱应用程序。 功能之一应该是每个成分/步骤的警报/计时器。 我猜 Ionic 是基于 Apa
我有一个 JS 计时器脚本,从 20 秒开始倒计时 var count = 0; var speed = 1000; countdown = setInterval( function
我的 JavaScript 计时器有一个大问题。一切正常,除了 1 个按钮:停止!我不知道如何停止计数器上的所有内容(例如重置每个输入和计数器)。有什么想法可以解决这个问题吗?
所以我有一个 TimerTask 任务 在其 run() 中调用函数 onTimerComplete() onTimerComplete() 看起来像这样: private void onTimerC
我在 Eclipse 中的 windowbuilder 创建的 run() 方法中有计时器。 我不知道如何通过另一种方法停止该计时器。例如通过添加 if(MenuWindow.gameStarted
我对java很陌生,我试图在按下按钮时启动计时器,但无法启动它。我尝试了几行代码,但似乎没有任何效果。 我已经声明了我的标签、文本字段和计时器: private JTextField JTFHours
import java.util.Scanner; import java.util.Timer; import java.util.TimerTask; public class Boggle {
我正在尝试在 JavaScript 中获取计时器的值,因此当计时器为零时它会显示不同的内容; var local_t = new Date(); local_t.setSeconds(local_t.
我需要使用 jquery 为网站创建自定义 slider 。到目前为止,如果我单击按钮,我已经设法让它按照我想要的方式运行,但我想实现一个自动计时器,以便幻灯片在 5 秒后切换。 这是我的 JS 代码
我正在制作一个计时器,记录点击“通过”按钮上的“确定”时的最长时间(个人最好成绩)。我似乎无法弄清楚如何让计数器回到 0,我确信有一种方法可以只用 2 个按钮(开始 + 通过)来完成。我希望计时器在我
我有一个 java.util.Timer 用于限制电子邮件发送(如果最近发送了状态电子邮件,那么现在不要发送,而是创建一个计时器任务以稍后发送任何新状态)。 我想要的是确保最终发送所有排队的电子邮件,
我已经建立了一个在线考试门户,允许学生使用网络浏览器在线参加考试。 现在我还开发了计时器功能,用户必须在规定的时间范围内完成考试。我遇到的麻烦是,当我刷新页面时,计时器再次从新开始,例如 40 分钟。
我想知道在一定时间内禁用按钮的最佳方法是什么。当用户使用其他按钮转到其他页面时,定时器不会被重置,按钮仍将被禁用。 我读过很多关于异步任务、线程的不同方法。但是我非常不确定哪种方法最好。 我希望计时器
我正在制作一个测验应用程序,我想在其中显示用户在玩游戏时所用的时间。它应该采用 HH:MM:SS 格式,从 00:00:00 开始,直到他选择答案。当用户每秒播放时,计时器应该每秒更新一次。另外,我想
您好,计划为该 Activity 开发 android 倒数计时器应用程序,当用户单击开始按钮时显示计时器倒计时并显示计时器倒计时,用户将转到剩余 Activity ,即使计时器在后台运行,如果用户单
我想知道是否有一种简单的方法可以使用 PHP 在数据库中创建计时器,我想在数据库中创建该行 30 分钟后将其删除。如果这不够具体,我很抱歉,但我不知道如何在其中提供更多细节,请随意发表评论,以便我可以
我试图制作一种与我的计时器一起使用的对象。问题是,当我只有裸函数(不在对象中)时,它就可以工作。但是当我把它放在对象内部时它不起作用。 使用此代码我只能看到 00:01 当我只使用函数本身时,它工作正
这个问题已经有答案了: How to format numbers as currency strings (67 个回答) 已关闭 9 年前。 我想显示从 1 到 2500 的美元计时器。当计时器增
我是一名优秀的程序员,十分优秀!