标签: queue

Asterisk 中的外部队列成员

我如何描述队列成员,以便将呼叫者转发到例如手机号码,例如:

queues.conf

[my_queue]
...
;local member
member => SIP/member1
;external member
member => SIP/external-provider/<member2's number> ;but this doesn't work
...
Run Code Online (Sandbox Code Playgroud)

queue mobile asterisk pbx

3
推荐指数
1
解决办法
6064
查看次数

如何获取运行任务的队列 - celery

我是使用 celery 的新手,有一个问题。我有这个简单的任务:

@app.task(name='test_install_queue')
def test_install_queue():
    return subprocess.call("exit 0",shell=True)
Run Code Online (Sandbox Code Playgroud)

我稍后会在类似的测试用例中调用此任务

result = tasks.test_default_queue.apply_async(queue="install")
Run Code Online (Sandbox Code Playgroud)

任务在队列中成功运行install(因为我在 celery 日志中看到它,并且它完成得很好。但我想知道一种以编程方式test_install_queue从存储在result.

谢谢!

编辑:

我已将任务更改为:

@app.task(name='test_install_queue',bind=True)
def test_install_queue(self):
    return self.request.__dict__
Run Code Online (Sandbox Code Playgroud)

然后我使用的结果apply_async如下:

result = tasks.test_install_queue.apply_async(queue="install")
assert "install" in result.get()["hostname"]
Run Code Online (Sandbox Code Playgroud)

解决方法是工作程序(主机名)与工作程序中初始化的唯一队列具有相同的名称。

python queue task celery

3
推荐指数
2
解决办法
4979
查看次数

使用两个堆栈实现队列的恒定摊销复杂度

方法:维护两个堆栈 A 和 B。推入 A。弹出查看 B。如果 B 为空,则将 A 完全弹出并将其推入 B,然后从 B 弹出。否则简单地从 B 弹出。

问题:1)运行时间和摊销运行时间有什么区别?2)为什么这里的摊销运行时间是常数?它不会随着输入数量的增加以及我们决定从它弹出时增加吗?因为如果我们继续推动,那么 A 会填满很多,而 B 是空的。现在,如果我们决定从 B 弹出,那么我需要复制所有 A 然后弹出。

queue complexity-theory stack asymptotic-complexity amortized-analysis

3
推荐指数
2
解决办法
5117
查看次数

带数据帧的多处理和队列

我在通过队列在 2 个进程之间交换对象(数据帧)时遇到了一些麻烦。

第一个进程从队列中获取数据,第二个进程将数据放入队列。put-process 更快,所以 get-process 应该通过读取所有对象来清除队列。

我有奇怪的行为,因为我的代码按预期完美运行,但仅适用于数据帧中的 100 行,对于 1000 行,get-process 始终只需要 1 个对象。

import multiprocessing, time, sys
import pandas as pd

NR_ROWS = 1000
i = 0
def getDf():
    global i, NR_ROWS
    myheader = ["name", "test2", "test3"]                
    myrow1 =   [ i,  i+400, i+250]
    df = pd.DataFrame([myrow1]*NR_ROWS, columns = myheader)
    i = i+1
    return df 


def f_put(q):
    print "f_put start"        

    while(1): 
        data = getDf()                
        q.put(data)
        print "P:", data["name"].iloc[0]         
        sys.stdout.flush()                    
        time.sleep(1.55)


def f_get(q):
    print "f_get start"    

    while(1):     
        data = pd.DataFrame() …
Run Code Online (Sandbox Code Playgroud)

python queue multiprocessing pandas python-multiprocessing

3
推荐指数
1
解决办法
4712
查看次数

在不同模块中运行的线程之间共享队列

我的项目在不同的包中有一些模块。这个项目需要几个可能在不同模块中启动的线程,我打算使用队列进行线程间通信。

有没有办法传递在一个模块中创建的队列以供另一个模块使用?

# ModuleA.py    

myQueue = Queue.Queue()
thread = myThread(threadID1, tName1, myQueue)
thread2 = myThread(threadID2, tName2, myQueue)

# ModuleB.py

myQueue = get_the_previous_queue_created() # possible?
thread3 = myThread(threadID3, tName3, myQueue)
Run Code Online (Sandbox Code Playgroud)

python queue multithreading python-2.7

3
推荐指数
1
解决办法
1798
查看次数

Laravel 如何设置或定义工人数量?

在 Laravel 中,您可以使用以下命令启动队列侦听器:

php artisan queue:listen
Run Code Online (Sandbox Code Playgroud)

但是有多少工人(线程、进程)将用于处理队列?
有没有办法定义工人的数量?

php queue laravel

3
推荐指数
2
解决办法
4098
查看次数

如何使用动态分配的数组实现队列?

我想使用动态分配的数组来实现队列。这带来了一些我不确定如何处理的问题。如何检查队列是否为空?如何在一个时刻跟踪队列中的元素数量?

对于第二个问题,我想我可以创建一个变量来跟踪队列中随时更新的元素数量realloc()。不过,我欢迎其他建议。

如果您还有其他我应该考虑的考虑事项,请提出。

c queue dma

3
推荐指数
1
解决办法
6638
查看次数

如何实现 Laravel Redis 限速

尝试为队列实现速率限制以每秒运行一项作业,该作业向外部 API 发出 HTTP 请求并加载一种类型的数据。

但不知道如何称呼这份工作,尝试了不同的选择但没有奏效。在示例中:

Redis::throttle('key')->allow(10)->every(60)->then(function () {
    // Job logic...
}, function () {
    // Could not obtain lock...
    return $this->release(10);
});
Run Code Online (Sandbox Code Playgroud)

将在// Job logic...调度队列中放入什么并且此代码将在队列类中?以及如何命名key?我的队列名称是loader.

有什么帮助吗?

queue throttling redis laravel

3
推荐指数
1
解决办法
6145
查看次数

Laravel - 作业报告失败(即使它正确退出)

我正在使用最新版本的 Homestead。我也设置了 Laravel Horizo​​n。我使用 Redis 作为队列驱动程序。Laravel 是 5.6 版,是全新安装的。

发生的事情是我的工作都失败了(即使工作正确退出)。

我使用自定义命令通过命令行运行作业:

vagrant@homestead:~/myapp$ artisan crawl:start
vagrant@homestead:~/myapp$ <-- No CLI errors after running
Run Code Online (Sandbox Code Playgroud)

应用程序/控制台/命令/crawl.php

<?php

namespace MyApp\Console\Commands;

use Illuminate\Console\Command;
use MyApp\Jobs\Crawl;

class crawl extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'crawl:start';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Start long running job.';

    /**
     * Create a new command instance.
     *
     * …
Run Code Online (Sandbox Code Playgroud)

php queue laravel laravel-horizon

3
推荐指数
1
解决办法
3536
查看次数

RabbitMQ 队列和路由键

In documentation https://docs.spring.io/spring-amqp/reference/htmlsingle/ i see

@RabbitListener(bindings = @QueueBinding(
        value = @Queue(value = "myQueue", durable = "true"),
        exchange = @Exchange(value = "auto.exch", ignoreDeclarationExceptions = "true"),
        key = "orderRoutingKey")
  )
  public void processOrder(Order order) {

  }

  @RabbitListener(bindings = @QueueBinding(
        value = @Queue,
        exchange = @Exchange(value = "auto.exch"),
        key = "invoiceRoutingKey")
  )
  public void processInvoice(Invoice invoice) {

  }
Run Code Online (Sandbox Code Playgroud)

Here 1 queue and 2 another routing keys, everyone for his method But my code doesn't get message from key!

    @RabbitListener(bindings = @QueueBinding(
            value = …
Run Code Online (Sandbox Code Playgroud)

java queue spring rabbitmq

3
推荐指数
1
解决办法
4385
查看次数