Issue 1:
Error happens when there's some queues already added before worker started and max task per child is 1

Checklist

I have included the output of celery -A proj report in the issue.

software -> celery:4.1.0 (latentcall) kombu:4.1.0 py:2.7.12

billiard:3.5.0.3 py-amqp:2.2.2

platform -> system:Linux arch:64bit, ELF imp:CPython

loader -> celery.loaders.app.AppLoader

settings -> transport:amqp results:disabled

I have verified that the issue exists against the master branch of Celery.

Steps to reproduce

create instance of QApplication when main worker started

@celeryd_after_setup.connect
from PyQt4.QtGui import QApplication
def init_worker(sender, **k):
QApplication([])

create task

@app.task
def job():
print 'hello'

add some queues (2 - 3 per thread. so if there's 4 worker child then there's 8 or more queues)

start worker with max task per child 1

celery worker -A proj --loglevel=INFO --max-tasks-per-child=1

Expected behavior

run queues successfuly

Actual behavior

Celery Crash after 1 queue per child

2017-12-07 10:20:19,594: INFO/MainProcess] Received task: proj.tasks.job[c6413dc2-ad62-4033-a69b-39556276f789]
[2017-12-07 10:20:19,595: INFO/MainProcess] Received task: proj.tasks.job[f1c10b1c-03ae-4220-9c7f-2cdf4afc61e3]
[2017-12-07 10:20:19,596: INFO/MainProcess] Received task: proj.tasks.job[d54f4554-4517-470f-8e14-adedcb93a46e]
[2017-12-07 10:20:19,596: INFO/MainProcess] Received task: proj.tasks.job[6255e5e6-d4c8-4d87-8075-642bca9e6a6d]
[2017-12-07 10:20:19,700: INFO/ForkPoolWorker-1] Task proj.tasks.job[ca856d5c-f3cc-45d4-9fbc-665753f5d1d2] succeeded in 0.00115608799388s: None
[2017-12-07 10:20:19,701: INFO/ForkPoolWorker-4] Task proj.tasks.job[9ae27611-e8e5-4e08-9815-1e56e2ad1565] succeeded in 0.00130111300678s: None
[2017-12-07 10:20:19,701: INFO/ForkPoolWorker-3] Task proj.tasks.job[f5aa7c6a-4142-4a38-8814-c60424196826] succeeded in 0.00129756200477s: None
[2017-12-07 10:20:19,702: INFO/ForkPoolWorker-2] Task proj.tasks.job[eb13b5c5-8865-4992-8b9e-6672c909fd59] succeeded in 0.00100053900678s: None
[2017-12-07 10:20:19,710: INFO/MainProcess] Received task: proj.tasks.job[01700061-c69c-4f4c-abf2-e6ba200772bd]
[2017-12-07 10:20:19,711: INFO/MainProcess] Received task: proj.tasks.job[a27d7a7b-2c58-4689-8b98-2c0a4ceaea9f]
[2017-12-07 10:20:19,713: INFO/MainProcess] Received task: proj.tasks.job[4c4a5685-23d5-4178-89cc-9ce4ad5a3509]
[2017-12-07 10:20:19,714: INFO/MainProcess] Received task: proj.tasks.job[44a079a3-aacf-48c5-a76b-a061bdced1d6]
[2017-12-07 01:41:03,591: CRITICAL/MainProcess] Unrecoverable error: AttributeError("'error' object has no attribute 'errno'",)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/worker/worker.py", line 203, in start
self.blueprint.start(self)
File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 370, in start
return self.obj.start()
File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer/consumer.py", line 320, in start
blueprint.start(self)
File "/usr/local/lib/python2.7/dist-packages/celery/bootsteps.py", line 119, in start
step.start(parent)
File "/usr/local/lib/python2.7/dist-packages/celery/worker/consumer/consumer.py", line 596, in start
c.loop(*c.loop_args())
File "/usr/local/lib/python2.7/dist-packages/celery/worker/loops.py", line 88, in asynloop
next(loop)
File "/usr/local/lib/python2.7/dist-packages/kombu/async/hub.py", line 354, in create_loop
cb(*cbargs)
File "/usr/local/lib/python2.7/dist-packages/celery/concurrency/asynpool.py", line 444, in _event_process_exit
self.maintain_pool()
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 1307, in maintain_pool
self._maintain_pool()
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 1298, in _maintain_pool
joined = self._join_exited_workers()
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 1165, in _join_exited_workers
self.process_flush_queues(worker)
File "/usr/local/lib/python2.7/dist-packages/celery/concurrency/asynpool.py", line 1175, in process_flush_queues
readable, _, _ = _select(fds, None, fds, timeout=0.01)
File "/usr/local/lib/python2.7/dist-packages/celery/concurrency/asynpool.py", line 183, in _select
if exc.errno == errno.EINTR:
AttributeError: 'error' object has no attribute 'errno'

Issue 2:
We are seeing the above mentioned error.

Coming from:

https://github.com/celery/celery/blob/master/celery/concurrency/asynpool.py#L182

A quick test on this test in the REPL reproduces this error:

Python 2.7.13 (default, Apr 4 2017, 08:46:44)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import select
>>> select.error
<class 'select.error'>
>>> moshe = select.error()
>>> moshe.errorno
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'error' object has no attribute 'errorno'

With the socket class however, this works just fine:

>>> import socket
>>> socket.error
<class 'socket.error'>
>>> moshe = socket.error()
>>> moshe.errno

Given that this code is in place since 2013, maybe I am doing something wrong here?