10000 Now requires billiard 3.4b1 · alex-python/celery@0a9fd7e · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a9fd7e

Browse files
committed
Now requires billiard 3.4b1
1 parent 3ef84b7 commit 0a9fd7e

File tree

2 files changed

+7
-47
lines changed

2 files changed

+7
-47
lines changed

celery/concurrency/asynpool.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def _select(readers=None, writers=None, err=None, timeout=0,
179179

180180
class Worker(_pool.Worker):
181181
"""Pool worker process."""
182-
dead = False
183182

184183
def on_loop_start(self, pid):
185184
# our version sends a WORKER_UP message when the process is ready
@@ -351,6 +350,11 @@ class AsynPool(_pool.Pool):
351350
ResultHandler = ResultHandler
352351
Worker = Worker
353352

353+
def WorkerProcess(self, worker):
354+
worker = super(AsynPool, self).WorkerProcess(worker)
355+
worker.dead = False
356+
return worker
357+
354358
def __init__(self, processes=None, synack=False,
355359
sched_strategy=None, *args, **kwargs):
356360
self.sched_strategy = SCHED_STRATEGIES.get(sched_strategy,

celery/platforms.py

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
from billiard.process import current_process
2626
except ImportError:
2727
current_process = None
28+
from billiard.compat import get_fdmax, close_open_fds
2829
# fileno used to be in this module
2930
from kombu.utils import maybe_fileno
3031
from kombu.utils.encoding import safe_str
3132
from contextlib import contextmanager
3233

3334
from .local import try_import
34-
from .five import items, range, reraise, string_t, zip_longest
35-
from .utils.functional import uniq
35+
from .five import items, reraise, string_t
3636

3737
_setproctitle = try_import('setproctitle')
3838
resource = try_import('resource')
@@ -110,26 +110,6 @@ class LockFailed(Exception):
110110
"""Raised if a pidlock can't be acquired."""
111111

112112

113-
def get_fdmax(default=None):
114-
"""Return the maximum number of open file descriptors
115-
on this system.
116-
117-
:keyword default: Value returned if there's no file
118-
descriptor limit.
119-
120-
"""
121-
try:
122-
return os.sysconf('SC_OPEN_MAX')
123-
except:
124-
pass
125-
if resource is None: # Windows
126-
return default
127-
fdmax = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
128-
if fdmax == resource.RLIM_INFINITY:
129-
return default
130-
return fdmax
131-
132-
133113
class Pidfile(object):
134114
"""Pidfile
135115
@@ -268,30 +248,6 @@ def _create_pidlock(pidfile):
268248
return pidlock
269249

270250

271-
if hasattr(os, 'closerange'):
272-
273-
def close_open_fds(keep=None):
274-
# must make sure this is 0-inclusive (Issue #1882)
275-
keep = list(uniq(sorted(
276-
f for f in map(maybe_fileno, keep or []) if f is not None
277-
)))
278-
maxfd = get_fdmax(default=2048)
279-
kL, kH = iter([-1] + keep), iter(keep + [maxfd])
280-
for low, high in zip_longest(kL, kH):
281-
if low + 1 != high:
282-
os.closerange(low + 1, high)
283-
284-
else:
285-
286-
def close_open_fds(keep=None): # noqa
287-
keep = [maybe_fileno(f)
288-
for f in (keep or []) if maybe_fileno(f) is not None]
289-
for fd in reversed(range(get_fdmax(default=2048))):
290-
if fd not in keep:
291-
with ignore_errno(errno.EBADF):
292-
os.close(fd)
293-
294-
295251
class DaemonContext(object):
296252
_is_open = False
297253

0 commit comments

Comments
 (0)
0