title: Celery worker disconnects to broker
body: <p>I am using <code>Python</code> with <code>RabbitMQ</code> and <code>Celery</code> to distribute tasks to a worker. The tasks take around 15 minutes each and are 99% CPU-bound. My system has 24-cores and whenever my worker executes this task, I get a connection error to the broker.</p>
  <pre><code>[2019-10-12 08:49:57,695: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...
  [...]
  ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
  </code></pre>
  <p>I found several other posts with this issue, but none of them fixed it. Especially with the heavy CPU load, any idea how I could solve that?</p>
  <blockquote>
  <p>Windows 10 (worker)</p>
  <p>macOS 10.14 (RabbitMQ Server)</p>
  <p>Python <strong>3.7</strong></p>
  <p>Celery <strong>4.3.0</strong> (rhubarb)</p>
  <p>RabbitMQ <strong>3.7.16</strong> (Erlang <strong>22.0.7</strong>)</p>
  </blockquote>
  <p>My configuration lets the worker consume only <strong>1 task at a time</strong>, and even the worker process is restarted after each job, still no luck:</p>
  <pre><code>CELERYD_MAX_TASKS_PER_CHILD = 1,
  CELERYD_CONCURRENCY = 1,
  CELERY_TASK_RESULT_EXPIRES=3600,
  CELERYD_PREFETCH_MULTIPLIER = 1,
  CELERY_MAX_CACHED_RESULTS = 1,
  CELERY_ACKS_LATE = True,
  </code></pre>
  <p>And this is the entire callstack:</p>
  <pre><code>[2019-10-12 08:49:57,695: WARNING/MainProcess] consumer: Connection to broker lost. Trying to re-establish the connection...
  Traceback (most recent call last):
  File &quot;C:\Python37\lib\site-packages\celery\worker\consumer\consumer.py&quot;, line 318, in start
      blueprint.start(self)
  File &quot;C:\Python37\lib\site-packages\celery\bootsteps.py&quot;, line 119, in start
      step.start(parent)
  File &quot;C:\Python37\lib\site-packages\celery\worker\consumer\consumer.py&quot;, line 596, in start
      c.loop(*c.loop_args())
  File &quot;C:\Python37\lib\site-packages\celery\worker\loops.py&quot;, line 118, in synloop
      qos.update()
  File &quot;C:\Python37\lib\site-packages\kombu\common.py&quot;, line 442, in update
      return self.set(self.value)
  File &quot;C:\Python37\lib\site-packages\kombu\common.py&quot;, line 435, in set
      self.callback(prefetch_count=new_value)
  File &quot;C:\Python37\lib\site-packages\celery\worker\consumer\tasks.py&quot;, line 47, in set_prefetch_count
      apply_global=qos_global,
  File &quot;C:\Python37\lib\site-packages\kombu\messaging.py&quot;, line 558, in qos
      apply_global)
  File &quot;C:\Python37\lib\site-packages\amqp\channel.py&quot;, line 1853, in basic_qos
      wait=spec.Basic.QosOk,
  File &quot;C:\Python37\lib\site-packages\amqp\abstract_channel.py&quot;, line 68, in send_method
      return self.wait(wait, returns_tuple=returns_tuple)
  File &quot;C:\Python37\lib\site-packages\amqp\abstract_channel.py&quot;, line 88, in wait
      self.connection.drain_events(timeout=timeout)
  File &quot;C:\Python37\lib\site-packages\amqp\connection.py&quot;, line 504, in drain_events
      while not self.blocking_read(timeout):
  File &quot;C:\Python37\lib\site-packages\amqp\connection.py&quot;, line 509, in blocking_read
      frame = self.transport.read_frame()
  File &quot;C:\Python37\lib\site-packages\amqp\transport.py&quot;, line 252, in read_frame
      frame_header = read(7, True)
  File &quot;C:\Python37\lib\site-packages\amqp\transport.py&quot;, line 438, in _read
      s = recv(n - len(rbuf))
  ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
  </code></pre>