title: Python w/ Celery and RabbitMQ Does Not Behave Normally
body: <p>I'm using Django 1.4.3 with Python 2.7, Celery 3.0.1 and django-celery 3.0.17 on Ubuntu 13.04.</p>
  
  <p>I have some tasks setup to run time consuming processes.  If I set them up to queue with celery they do not behave properly.  If I run them without queuing them everything behaves perfectly.  Any thoughts as to why this would be the case?</p>
  
  <p>To provide some motivation to my problem.  I need to clone company contracts.  Each contract has multiple offers associated with it.  Each offer has multiple offer fields.  Each offer field has multiple values.  I need to clone everything.</p>
  
  <p>Here is an example of what I'm doing.</p>
  
  <pre><code>def clone_contract(self, contract_id, contract_name):
      old_contract = models.Contract.objects.get(pk=contract_id)
      contract_dict = dict()
      for attr in old_contract._meta.fields:
          contract_dict[attr.name] = getattr(old_contract, attr.name)
      del contract_dict['id']
      contract_dict['name'] = contract_name
      new_contract = contracts_models.Contract(**contract_dict)
      new_contract.save()
      contracts_tasks.clone_offers.delay(new_contract, old_contract)
  
  @task(name='Clone Offers')
  def clone_offers(new_contract, old_contract):
      for offer in old_contract.offer_set.all():
          offer_dict = dict()
          for attr in offer._meta.fields:
              offer_dict[attr.name] = getattr(offer, attr.name)
          del offer_dict['id']
          del offer_dict['contract']
          offer_dict['contract_id'] = new_contract.pk
          new_offer = contracts_models.Offer(**offer_dict)
          new_offer.save()
          clone_offer_fields(new_offer, offer)
  
  def clone_offer_fields(new_offer, old_offer):
      offer_fields = models.OfferField.objects.filter(offer=old_offer)
      for offer_field in offer_fields:
          initial = dict()
          for attr in offer_field._meta.fields:
              initial[attr.name] = getattr(offer_field, attr.name)
          initial['offer'] = new_offer
          del initial['id']
          new_offer_field = contracts_models.OfferField(**initial)
          new_offer_field.save()
          model = models.OfferFieldValue
          values = model.objects.filter(**{'field': offer_field})
          clone_model(new_offer_field, model, 'field', values)
  
  def clone_model(new_obj, model, fk_name, values):
      for value in values:
          initial = dict()
          for attr in value._meta.fields:
              initial[attr.name] = getattr(value, attr.name)
          del initial['id']
          initial[fk_name] = new_obj
          new_value = model(**initial)
          new_value.save()
  </code></pre>
  
  <p>From what I've observed the <code>clone_offers</code> works but the <code>clone_offer_fields</code> does not - again, only if <code>clone_offers</code> gets called as <code>clone_offers.delay()</code>.  If I run this calling <code>clone_offers</code> without <code>.delay()</code> (not queuing it) everything works perfectly.</p>
  
  <p>Unfortunately I'm unable to log in queued tasks (nothing seems to be written to the log file) so I can't troubleshoot within the code.</p>
  
  <p>Is there an issue calling functions within a queued task?  I'm pretty sure I've done this before with no problems.  (Edit:  Answered below)</p>
  
  <p>Any suggestions would be greatly appreciated.</p>
  
  <p>EDIT1:
  I decided to test this throwing all the methods together.  I was 99% sure this wouldn't be the problem but thought it'd be better to check to make sure.  No difference if I use a single massive method.</p>