标签: task-queue

Laravel 测试作业已发布

我想测试在某些情况下该作业是否已被释放回队列中。

这是我的工作类别:

class ChargeOrder extends Job
{
    use InteractsWithQueue, SerializesModels;

    /**
     * The order model which is to be charged
     */
    protected $order;

    /**
     * The token or card_id which allows us to take payment
     */
    protected $source;

    /**
     * Create a new job instance.
     *
     * @param   App\Order       $order;
     * @param   string          $source;
     * @return  array
     */
    public function __construct($order, $source)
    {
        $this->order        = $order;
        $this->source       = $source;
    }

    /**
     * Execute the job.
     *
     * @return void
     */ …
Run Code Online (Sandbox Code Playgroud)

testing jobs task-queue laravel

5
推荐指数
1
解决办法
3354
查看次数

如何在不运行异步方法的情况下对它的任务结果进行排队?

如果我有一个类,其中包含稍后要执行的任务队列,并且我有一个async Task<T>方法,那么如何将该异步方法排入队列而不执行它?

我想“延迟”此任务,并确保调用者看到它稍后运行,就像在方法体中等待它一样。--- 调用者不应该知道我已将任务排队以供稍后使用。

现在,如果我的队列已满,我会构造并返回一个Task<T>未运行的新的,它返回.Result我的私有异步方法:

public async Task<T> ExecuteAsync<T>(T transaction) {
    if (mustDelay) {
        Task<T> task = new Task<T>(t => executeAsync((T) t).Result, transaction);
        enqueue(task);
        return await task;
    }
    return await executeAsync(transaction);
}

private async Task<T> executeAsync<T>(T transaction) {
    await someWork();
    return transaction;
}
Run Code Online (Sandbox Code Playgroud)

当其他任务完成时,我使Start()该任务出队:

dequeuedTask.Start();
Run Code Online (Sandbox Code Playgroud)

这是否确保调用者看到与仅从方法返回等待结果相同的同步?

c# asynchronous task task-queue

5
推荐指数
1
解决办法
2962
查看次数

为什么 Laravel 队列忽略我的超时值?

为什么我的队列作业超时?我使用数据库作为驱动程序我尝试了以下操作:

class PdfGenerator implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $userData;
    protected $filename;
    protected $path;
    public $timeout = 1200;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($userData, $filename)
    {
        //
        $this->userData = $userData;
        $this->filename = $filename;
        $this->path = \public_path('\\pdfs\\'.$this->filename.'.pdf');
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $pdf = App::make('snappy.pdf.wrapper');
        $footer = \view('supporting.footer')->render();
        $header = \view('supporting.header')->render();
        //$userData = \collect([$this->userData[1]]);
        $pdf->loadView('order_clean', ['users' => $this->userData])
        ->setOption('margin-top', …
Run Code Online (Sandbox Code Playgroud)

php task-queue laravel laravel-8

5
推荐指数
1
解决办法
3794
查看次数

Google app-engine任务队列任务名称中的特殊字符

任务队列中的任务名称中是否允许使用破折号( - )或任何其他特殊字符?

google-app-engine task-queue

4
推荐指数
1
解决办法
265
查看次数

App Engine中的自定义任务队列?

我创建了一个新的任务队列,并在queue.yaml中定义了它

我不确定如何开始向此队列添加任务?

使用默认队列,这是简单的taskqueue.add(...)

我们如何为自定义队列执行此操作?

google-app-engine task-queue

4
推荐指数
1
解决办法
1148
查看次数

Google App Engine任务队列 - 令人讨厌的失败

我正在为GAE开发一个应用程序并尝试使用任务队列.目前,我只是通过GAE App Launcher在我的Windows机器上运行这个东西,但每当我尝试排队任何东西时,开发'服务器'崩溃并且日志充满讨厌的输出.

taskqueue.add(url='/processWork', params={'key', myModel.key()})
Run Code Online (Sandbox Code Playgroud)

我已经尝试在与其他工作的交易中运行这个,所以我很确定这项工作是否成功入队.

然而,不久之后,开发服务器崩溃,日志中充满了这样的东西:

ERROR    2011-02-06 17:04:23,289
__init__.py:395] global name 'true' is not defined Traceback (most recent call last):   File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 517, in __call__
    handler.post(*groups)   File "C:\Projects\GAE\MyApp\main.py", line 114, in post
    activity.approved = true NameError: global name 'true' is not defined INFO     2011-02-06 17:04:23,309 dev_appserver.py:3317] "POST /processWork HTTP/1.1" 500 - WARNING  2011-02-06 17:04:23,309 taskqueue_stub.py:586] Task named "task1" on queue "default" failed with code 500; will retry in 30 seconds Traceback (most recent call …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine task-queue

4
推荐指数
2
解决办法
1664
查看次数

在Google应用引擎中将任务添加到非默认队列

我正在尝试使用以下命令将任务添加到非默认队列"slowQueue":

taskqueue.Queue('slowQueue').add(url='/worker/slow', params={'name': name})
Run Code Online (Sandbox Code Playgroud)

我收到错误"TypeError:add()得到一个意外的关键字参数'url'"

如何将任务添加到谷歌应用引擎中的非默认队列?

python google-app-engine task-queue

4
推荐指数
2
解决办法
842
查看次数

Google App Engine:确定当前请求是否为任务队列

有没有办法动态确定当前正在执行的任务是标准的http请求还是TaskQueue?

在我的请求处理程序的某些部分,我做了几个urlfetches.如果请求是标准的http请求,我希望url fetch的超时延迟很短,如果是TaskQueue,则需要很长时间.

python google-app-engine task-queue

4
推荐指数
1
解决办法
895
查看次数

如何在队列中放置和获取一组多个项目?

工人:

def worker():
    while True:
        fruit, colour = q.get()
        print 'A ' + fruit + ' is ' + colour
        q.task_done()
Run Code Online (Sandbox Code Playgroud)

将项目放入队列:

fruit = 'banana'
colour = 'yellow'
q.put(fruit, colour)
Run Code Online (Sandbox Code Playgroud)

输出:

>>> A banana is yellow
Run Code Online (Sandbox Code Playgroud)

我怎么能做到这一点?我试了一下ValueError: too many values to unpack,然后我意识到我q.put()将两个变量放入队列.

有没有办法将一组"变量/对象"放入一个队列项中,就像我试图做的那样?

python variables task-queue

4
推荐指数
1
解决办法
7281
查看次数

浏览器中的事件循环和任务队列之间有区别吗?

我对这个问题的答案中的一些术语感到有些困惑:JavaScript中的事件优先级是什么?

事件循环和任务队列之间有区别吗?这些队列有多大?

因为当我使用setInterval()设置Interval并使用alert()中断它时,会在警报显示的时间内删除间隔.

javascript event-loop javascript-events setinterval task-queue

4
推荐指数
1
解决办法
2422
查看次数