getting task by name from taskqueue

  • Last Update :
  • Techknowledgy :

How can I get a task by name?

from google.appengine.api
import taskqueue
taskqueue.add(name = 'foobar', url = '/some-handler', params = {
         'foo': 'bar'
      }

      task_queue = taskqueue.Queue('default') task_queue.delete_tasks_by_name('foobar') # would work

      # looking
      for a method like this:
      foobar_task = task_queue.get_task_by_name('foobar')

Suggestion : 2

A TaskQueue instance resource is represented by the following properties.,To create TaskQueues with the TargetWorkers expressions explained above, you could issue the following requests:,Note: By default, this will return the first 50 TaskQueues. Supply a PageSize parameter to fetch more than 50 TaskQueues. See paging for more information.,Skills-based distribution models, where workers are assigned integer values reflecting their expertise in a given skill, are also possible. The TaskQueues created below use skills-based routing to choose the best worker based on a 'tech_support_skill' attribute:

GET / v1 / Workspaces / {
   WorkspaceSid
}
/TaskQueues
curl https: //taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskQueues  \
   -d FriendlyName = EnglishSupport\ -
   d TargetWorkers = '(skills HAS "support") AND (languages HAS "english")'\ -
   d AssignmentActivitySid = {
      ActivitySid
   } -
   d ReservationActivitySid = {
      ActivitySid
   } -
   u {
      AccountSid
   }: {
      AuthToken
   }
curl https: //taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskQueues  \
   -d FriendlyName = SpanishDefault\ -
   d TargetWorkers = '(languages HAS "spanish")'\ -
   d AssignmentActivitySid = {
      ActivitySid
   } -
   d ReservationActivitySid = {
      ActivitySid
   } -
   u {
      AccountSid
   }: {
      AuthToken
   }
curl https: //taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/TaskQueues  \
   -d FriendlyName = "Tech Support – Tier 1"\ -
   d TargetWorkers = "tech_support_skill < 5"\ -
   d AssignmentActivitySid = {
      ActivitySid
   } -
   d ReservationActivitySid = {
      ActivitySid
   } -
   u {
      AccountSid
   }: {
      AuthToken
   }

Suggestion : 3

If you want the worker running for a dedicated Queue, pass the name of the queue to the command like this:,If you want to apply the settings above for a specific queue, you can add --queue=... option to the command. In the following case, only myQueue will be modified.,You can run this script if you want to be sure that the required queues and the task log container are created.,You can limit the iteration of the worker. It can be used only on a dedicated queue.

 $ composer require oat - sa / extension - tao - task - queue
use oat\ tao\ model\ taskQueue\ QueueDispatcher;
use oat\ tao\ model\ taskQueue\ Queue;
use oat\ taoTaskQueue\ model\ QueueBroker\ RdsQueueBroker;
use oat\ taoTaskQueue\ model\ QueueBroker\ SqsQueueBroker;
use oat\ tao\ model\ taskQueue\ TaskLogInterface;
use oat\ tao\ model\ taskQueue\ QueueDispatcherInterface;

$queueService = new QueueDispatcher(array(
   QueueDispatcherInterface::OPTION_QUEUES => [
      new Queue('priority', new SqsQueueBroker('default', \common_cache_Cache::SERVICE_ID, 10), 90),
      new Queue('standard', new RdsQueueBroker('default', 5), 30),
      new Queue('background', new RdsQueueBroker('default', 5), 10)
   ],
   QueueDispatcherInterface::OPTION_TASK_LOG => TaskLogInterface::SERVICE_ID,
   QueueDispatcherInterface::OPTION_TASK_TO_QUEUE_ASSOCIATIONS => [
      SomeImportantAction::class => 'priority',
      SomeLessImportantTask::class => 'standard'
   ]
));

$queueService - > setOption(QueueDispatcherInterface::OPTION_DEFAULT_QUEUE, 'background');

$this - > getServiceManager() - > register(QueueDispatcherInterface::SERVICE_ID, $queueService);
try {
   $queueService - > initialize();
} catch (\Exception $e) {
   return\ oat\ oatbox\ reporting\ Report::createError('Initializing queues failed');
}
 $ sudo - u www - data php index.php 'oat\taoTaskQueue\scripts\tools\InitializeQueue'
 $ sudo - u www - data php index.php 'oat\taoTaskQueue\scripts\tools\InitializeQueue'--broker = memory
 $ sudo - u www - data php index.php 'oat\taoTaskQueue\scripts\tools\InitializeQueue'--broker = rds--persistence =
    default --receive = 10