标签: task

如何每15分钟在Plesk设置一个cron任务?

我是Plesk的新手,我想知道如何设置执行http地址的cron任务,这是更新配置文件.我当然有链接,我希望每天24小时每15分钟不停地运行此链接.

如果你们能帮助我,我会很高兴的.

这是我对root的cron任务配置:

cron任务配置

我应该分钟,小时,每天填写什么?命令怎么样?

谢谢你的帮助,迈克

cron task plesk

7
推荐指数
1
解决办法
8664
查看次数

Thread.Sleep(2500)vs. Task.Delay(2500).Wait()

我想要清楚一点.我知道Task.Delay内部会使用一个Timer,它显然是基于任务的(等待),但Thread.Sleep会导致线程被阻塞.但是,在任务上调用.Wait会导致线程被阻塞吗?

如果没有,人们会认为这Task.Delay(2500).Wait()比好Thread.Sleep(2500).这跟我所说的SO问题/答案略有不同.Wait().

c# multithreading task task-parallel-library async-await

7
推荐指数
2
解决办法
5616
查看次数

任务.什么时候不等

我正在学习如何在控制台应用程序中使用异步函数,但无法使Task.WhenAll等到所有任务完成.以下代码有什么问题?它同步工作.先感谢您.

static void Main(string[] args)
{
    ...
    IncluiValores(...);
    ...
}

static async void IncluiValores(...)
{
    Task<List<int>> res1 = att.GetAIDBAPI(att);
    Task<List<int>> res2 = att.GetAIDBAPI(att2);

    List<int>[] res = await Task.WhenAll(res1, res2);

    ...
}
Run Code Online (Sandbox Code Playgroud)

更新 - 功能定义:

    public async Task<List<int>> GetAIDBAPI(Attributes attributes)
    {

        List<int> results = null;

        Connections client0 = new Connections();
        HttpClient client = client0.OpenAPIConnection(attributes.User[0], attributes.Pwd, attributes.Server, attributes.Chave, attributes.Server2);
        HttpResponseMessage response = await client.PostAsJsonAsync("api/Attributes/ID/Bulk", attributes);

        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            results = JsonConvert.DeserializeObject<dynamic>(content).ToObject<List<int>>();
        }
        else
        {
            var content = …
Run Code Online (Sandbox Code Playgroud)

c# task async-await

7
推荐指数
2
解决办法
3830
查看次数

任务调度程序 powershell 脚本永远不会结束

我有一个手动运行很好的脚本。但是,当我在 Task Scheduler 中安排它时,脚本永远不会结束,因此下次尝试运行时,它会失败,因为前一个实例仍在运行。脚本本身在第一次或手动运行时需要几秒钟才能完成。这是脚本:

$source = "\\server1\upload"
$destination = "\\server2\upload"
$logfile = "c:\Scripts\fileMover\log.txt"
$table = Get-ChildItem $source -include *
foreach ($file in $table){
    $filename = $file.FullName
    #write-host $filename
    try
    {
        move-item -LiteralPath $filename -destination $destination -force
        $body = "Successfully moved $filename to $destination"
        $subject = "fileMover Succeeded"
    }
    catch
    {
        $body = "Failed to move $filename to $destination"
        $subject = "fileMover Failed"
    }
    finally
    {
        $body | out-file $logfile -append -width 1000 -encoding ascii
        Send-MailMessage -To "filemoverconfirmations@domain.com" -From "uploader@domain.com" -Subject …
Run Code Online (Sandbox Code Playgroud)

powershell scheduler task

7
推荐指数
2
解决办法
8131
查看次数

Locust: how I share auth cookie with the rest of tasks only for current locust user?

I am looking into to moving my multi-threaded python script to locust.

A simple explanation of what my script does is:

  1. Create a thread per user
  2. In each thread authenticates user and get auth cookie
  3. With that auth cookie perform various api calls at a set interval

When i started looking into locust, I have noticed that the only way to perform each task at its own specific interval, I would need to create a taskset per task.

This brought …

python multithreading task locust taskset

7
推荐指数
1
解决办法
6822
查看次数

AspNetCore(Kestrel)请求超时

我有以下设置:在应用程序负载均衡器(AWS)后面的几个Linux容器(构建在aspnetcore 2.0.5上)中运行的web api

使用HttpClient向此api发出请求的客户端.客户端并行运行多个任务的调用.如果并行任务的数量增加,则api开始抛出异常并显示消息"请求超时".

调用堆栈是:

在Microsoft.AspNetCore的Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.PipeCompletion.ThrowFailed()在Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.GetResult(ReadResult&result)上Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO中的.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.IReadableBufferAwaiter.GetResult() .Pipelines.ReadableBufferAwaitable.GetResult()at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.d__24.MoveNext()---从抛出异常的上一个位置的堆栈跟踪结束---在System. Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.d__2.MoveNext()中的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中的Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

什么可能导致此错误,谁设置超时,我该如何进一步调查?

编辑:如果我尝试使用fiddler来捕获失败的请求,则不再抛出错误(也许fiddler正在以较低程度的并行性打开连接).

c# task kestrel-http-server asp.net-core

7
推荐指数
1
解决办法
4944
查看次数

如何创建分层 CancellationTokenSource?

在我们的项目中,我们决定借助CancellationToken.

由于项目中作品的结构,我需要一个分层取消机制。通过分层,我的意思是父源取消会导致所有子源被递归取消,但子源取消不会传播到父源。

.NET 中是否有开箱即用的此类选项?如果没有,我不确定向父令牌注册委托是否足够,或者应该进一步考虑。

c# task task-parallel-library cancellation

7
推荐指数
2
解决办法
535
查看次数

是否可以将异步函数传递给 Swift 中的核心数据托管对象上下文?如果不是,那为什么?

我已经寻找了一种将异步函数传递到核心数据托管对象上下文的方法,但仍然找不到。我怀疑新的异步/等待并发模型的某些部分我不理解,但我不知道它是什么。

我想做的事:

// Grab an moc
let moc = container.newBackgroundContext()

// Enter an async context
Task {

    await moc.perform {

        // Get some object
        let obj = moc.object(with: anObjectID)
        
        // This is not possible because NSManagedObjectContext.perform only accepts
        // a synchronous block
        await obj.doSomeLongRunningProcess()

    }
}
Run Code Online (Sandbox Code Playgroud)

我觉得奇怪的是这是不可能的。我不确定它是否在 Core Data api 中还没有出现,因为 async/await 太新了,或者是否有一个很好的理由它是不可能的?

像这样包裹doSomeLongRunningProcess起来Task

await moc.perform {
    Task {
        let obj = moc.object(with: anObjectID)
        await obj.doSomeLongRunningProcess()
    }
}
Run Code Online (Sandbox Code Playgroud)

不起作用,因为内部Task在不同的线程上运行,最终会导致 CoreData 不一致。我有点希望它会继承上下文的线程,但事实并非如此。

我想要一种将异步函数传递给 的方法ManagedObjectContext,但如果失败,我想知道为什么它不起作用?

concurrency core-data task async-await swift

7
推荐指数
1
解决办法
1998
查看次数

我该如何修复任务已被破坏但仍处于待处理状态?

我有个问题。因此,每次用户在我的不和谐服务器上写入聊天消息时,我都会运行一个任务 - 它称为on_message. 所以我的机器人在这个事件中有很多事情要做,我经常遇到这种错误:

\n
Task was destroyed but it is pending!\ntask: <Task pending name='pycord: on_message' coro=<Client._run_event() done, defined at /Bots/gift-bot/discord/client.py:374> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f68a7bdfc10>()]>>\n
Run Code Online (Sandbox Code Playgroud)\n

所以我想如果我想解决这个问题,我需要加速我的代码。但遗憾的是,我不知道如何修复此错误。

\n

编辑:我集成了计时,这就是我打印的内容:

\n
Task was destroyed but it is pending!\ntask: <Task pending name='pycord: on_message' coro=<Client._run_event() done, defined at /Bots/gift-bot/discord/client.py:374> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f01063f98e0>()]>>\n2 if checks done - 7.867813110351562e-06\n5 if checks done - 0.0061550140380859375\nmysql checks done - 0.010785341262817383\ntask done - 0.13075661659240723\n2 if checks done - 8.344650268554688e-06\n5 if …
Run Code Online (Sandbox Code Playgroud)

python mysql task python-asyncio pycord

7
推荐指数
2
解决办法
1万
查看次数

我什么时候应该使用 asyncio.create_task?

我正在使用 Python 3.10,我对asyncio.create_task.

在下面的示例代码中,无论我是否使用asyncio.create_task. 似乎没有什么区别。

如何确定何时使用以及使用与不使用相比asyncio.create_task有何优势?asyncio.create_task

import asyncio
from asyncio import sleep

async def process(index: int):
    await sleep(1)
    print('ok:', index)

async def main1():
    tasks = []
    for item in range(10):
        tasks.append(asyncio.create_task(process(item)))
    await asyncio.gather(*tasks)

async def main2():
    tasks = []
    for item in range(10):
        tasks.append(process(item)) # Without asyncio.create_task
    await asyncio.gather(*tasks)

asyncio.run(main1())
asyncio.run(main2())
Run Code Online (Sandbox Code Playgroud)

python task coroutine python-3.x python-asyncio

7
推荐指数
1
解决办法
2014
查看次数