title: No response from celery worker with TensorFlow
body: <p>I am trying to use tensorflow in a celery worker. I encountered timeout rather than receiving response from the worker.</p>
  
  <p>I used following code:</p>
  
  <p>tasks.py</p>
  
  <pre><code>from celery import Celery
  from celery.signals import worker_init
  
  import tensorflow as tf
  
  app = Celery('tasks', backend='redis://localhost:6379/0', broker='redis://localhost:6379/0')
  
  class TFModel():
    def __init__(self):
      self.sess = tf.Session()
    def run(self):
      return self.sess.run(tf.constant('hello'))
  
  tf_model = None
  
  @worker_init.connect
  def on_worker_init(**_):
    global tf_model
    tf_model = TFModel()
    print(tf_model.run())
    return
  
  @app.task(time_limit=10)
  def run():
    return tf_model.run()
  </code></pre>
  
  <p>test.py</p>
  
  <pre><code>import time
  from tasks import run
  
  r=run.delay()
  while not r.ready():
    time.sleep(2)
  
  print(r.get())
  </code></pre>
  
  <p>I executed a worker with this command.</p>
  
  <p><code>$ celery -A tasks worker -l info -c 1</code></p>
  
  <p>When I executed the worker, <code>hello</code> was printed out, since <code>on_worker_init()</code> had <code>print(tf_model.run())</code>.
  This means that tensorflow works properly.</p>
  
  <p>Then, I ran:</p>
  
  <p><code>$ python test.py</code></p>
  
  <p>Then, I got:</p>
  
  <p><code>celery.backends.base.TimeLimitExceeded: TimeLimitExceeded(10,)</code></p>
  
  <p>What was wrong?
  How can I investigate what happened?</p>
  
  <p>My environment is:</p>
  
  <pre><code>python 3.5.1
  tensorflow 0.11.0
  celery 4.0.2
  </code></pre>
  
  <p>Thanks.</p>