# Buggy code
def on_process_alive(self, pid):
    """Called when reciving the :const:`WORKER_UP` message.

    Marks the process as ready to receive work.
    """
    try:
        proc = next(w for w in self._pool if w.pid == pid)
    except StopIteration:
        return logger.warning("process with pid=%s already exited", pid)
    assert proc.inqW_fd not in self._fileno_to_inq
    assert proc.inqW_fd not in self._all_inqueues
    self._waiting_to_start.discard(proc)
    self._fileno_to_inq[proc.inqW_fd] = proc
    self._fileno_to_synq[proc.synqW_fd] = proc
    self._all_inqueues.add(proc.inqW_fd)


# Traceback (OSError)
[user] celery.worker.consumer.consumer WARNING 2017-12-18 00:38:27,078 consumer:
Connection to broker lost. Trying to re-establish the connection...
Traceback (most recent call last):
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 320, in start
blueprint.start(self)
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/worker/consumer/consumer.py", line 596, in start
c.loop(*c.loop_args())
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/worker/loops.py", line 47, in asynloop
obj.controller.register_with_event_loop(hub)
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/worker/worker.py", line 217, in register_with_event_loop
description='hub.register',
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/bootsteps.py", line 151, in send_all
fun(parent, *args)
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/worker/components.py", line 178, in register_with_event_loop
w.pool.register_with_event_loop(hub)
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/concurrency/prefork.py", line 134, in register_with_event_loop
return reg(loop)
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/concurrency/asynpool.py", line 476, in register_with_event_loop
for fd in self._fileno_to_outq]
File "/home/user/.envs/user/lib/python3.6/site-packages/celery/concurrency/asynpool.py", line 476, in <listcomp>
for fd in self._fileno_to_outq]
File "/home/user/.envs/user/lib/python3.6/site-packages/kombu/async/hub.py", line 207, in add_reader
return self.add(fds, callback, READ | ERR, args)
File "/home/user/.envs/user/lib/python3.6/site-packages/kombu/async/hub.py", line 158, in add
self.poller.register(fd, flags)
File "/home/user/.envs/user/lib/python3.6/site-packages/kombu/utils/eventio.py", line 67, in register
self._epoll.register(fd, events)
OSError: [Errno 9] Bad file descriptor

# Fixed code
def on_process_alive(self, pid):
    """Called when receiving the :const:`WORKER_UP` message.

    Marks the process as ready to receive work.
    """
    try:
        proc = next(w for w in self._pool if w.pid == pid)
    except StopIteration:
        return logger.warning("process with pid=%s already exited", pid)
    assert proc.inqW_fd not in self._fileno_to_inq
    assert proc.inqW_fd not in self._all_inqueues
    self._waiting_to_start.discard(proc)
    self._fileno_to_inq[proc.inqW_fd] = proc
    self._fileno_to_synq[proc.synqW_fd] = proc
    self._all_inqueues.add(proc.inqW_fd)