Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Only connect to AMQP when posting task
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Lam committed Apr 21, 2015
1 parent 609720a commit 029c312
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions celery.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Celery
private $connection_details = array(); // array of strings required to connect
private $amqp = null; // AbstractAMQPConnector implementation

private $isConnected = false;

function __construct($host, $login, $password, $vhost, $exchange='celery', $binding='celery', $port=5672, $connector=false, $persistent_messages=false, $result_expire=0, $ssl_options = array() )
{
$ssl = !empty($ssl_options);
Expand Down Expand Up @@ -105,6 +107,12 @@ function PostTask($task, $args, $async_result=true,$routing_key="celery", $task_
{
throw new CeleryException("Args should be an array");
}

if (!$this->isConnected) {
$this->amqp->Connect($this->connection);
$this->isConnected = true;
}

$id = uniqid('php_', TRUE);

/* $args is numeric -> positional args */
Expand Down

0 comments on commit 029c312

Please sign in to comment.