calling eventlib/gevent patching#6322
Conversation
|
This pull request introduces 1 alert when merging b4c82a7 into 5ab26db - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging de1bf7d into 5ab26db - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert and fixes 1 when merging 32ee9f3 into 5ab26db - view on LGTM.com new alerts:
fixed alerts:
|
|
This pull request fixes 1 alert when merging dc8d20b into 5ab26db - view on LGTM.com fixed alerts:
|
|
looks like it's too late, i got a max-recursion error trying to open an ssl connection. |
|
This pull request introduces 1 alert and fixes 1 when merging af5d81c into 5fb1393 - view on LGTM.com new alerts:
fixed alerts:
|
|
seems lazy app passing |
yes, now i'm thinking how can I port the |
|
This pull request introduces 2 alerts and fixes 1 when merging 09403a7 into 5806976 - view on LGTM.com new alerts:
fixed alerts:
|
|
This pull request fixes 1 alert when merging cd48206 into 5806976 - view on LGTM.com fixed alerts:
|
|
This is still a draft, @auvipy, @thedrow - i'm happy to hear your feedback. The idea of this change is to instantiate the app lazily so that eventlet/gevent will patch the standard library before the app is imported. To achieve that I used a cached property on the click-context. and with this commandline: |
|
Oh I completely forgot about gevent/eventlet patching. The documentation wasn't updated yet. I'll read the entire issue first before I respond more thoroughly. |
thedrow
left a comment
There was a problem hiding this comment.
Some issues here are minor, some are major.
This is a release blocker for 5.0.0 GA so we need to urgently resolve this.
| @property | ||
| @functools.lru_cache(None) | ||
| def app(self): | ||
| return self._app() or get_current_app() |
There was a problem hiding this comment.
Please provide a docstring which explains what happens here.
| worker.params.extend(ctx.obj.app.user_options.get('worker', [])) | ||
| beat.params.extend(ctx.obj.app.user_options.get('beat', [])) | ||
| events.params.extend(ctx.obj.app.user_options.get('events', [])) | ||
| # worker.params.extend(ctx.obj.app.user_options.get('worker', [])) |
There was a problem hiding this comment.
We need this to support preload options.
There was a problem hiding this comment.
a compensation for that is done here:
https://github.com/celery/celery/pull/6322/files#diff-a6e64fe5a7c24a0e587e8c92e83b87b5R321
(of course, it is only a draft as it needs to be applied on beat and events as well. i wanted to get an approval for this idea before pursuing it)
there is a downside to this approach, but i'm not sure how else to get the user options only after the patching
| def convert(self, value, param, ctx): | ||
| # Pools like eventlet/gevent needs to patch libs as early | ||
| # as possible. | ||
| maybe_patch_concurrency(value) |
There was a problem hiding this comment.
I'm pretty sure that's the wrong hook for this.
There was a problem hiding this comment.
I'm open for suggestions.
My reasoning was to make it as close as possible to -P evaluation which is the only indication that patching is needed.
A possibility is to move this call to the command function itself, but then we can't reference the app in any of the click.options (bc it will cause the app to be imported and the patching to be too late)
| '--statedb', | ||
| cls=CeleryOption, | ||
| type=click.Path(), | ||
| callback=lambda ctx, _, value: value or ctx.obj.app.conf.worker_state_db, |
There was a problem hiding this comment.
This cannot be removed. The default value must be derived from the app if it is not supplied.
There was a problem hiding this comment.
It's not removed, only moved below, so the app will not be loaded too soon. See the call to worker.start in this function
There was a problem hiding this comment.
Let's address the other issues first and see if we can find the way to write this code as Click intended it to be written.
|
This pull request introduces 1 alert and fixes 1 when merging d2def45 into 6248d87 - view on LGTM.com new alerts:
fixed alerts:
|
|
This pull request fixes 1 alert when merging 7f650c3 into 6248d87 - view on LGTM.com fixed alerts:
|
diff --git a/celery/__init__.py b/celery/__init__.py
index 03a69a6b8..f2e406a9a 100644
--- a/celery/__init__.py
+++ b/celery/__init__.py
@@ -112,12 +112,6 @@ def _patch_gevent():
import gevent.signal
gevent.monkey.patch_all()
- if gevent.version_info[0] == 0: # pragma: no cover
- # Signals aren't working in gevent versions <1.0,
- # and aren't monkey patched by patch_all()
- import signal
-
- signal.signal = gevent.signal
def maybe_patch_concurrency(argv=None, short_opts=None,
diff --git a/celery/__main__.py b/celery/__main__.py
index b0557b185..e865ea4bd 100644
--- a/celery/__main__.py
+++ b/celery/__main__.py
@@ -2,15 +2,15 @@
import sys
-# from . import maybe_patch_concurrency
+from . import maybe_patch_concurrency
__all__ = ('main',)
def main():
"""Entrypoint to the ``celery`` umbrella command."""
- # if 'multi' not in sys.argv:
- # maybe_patch_concurrency()
+ if 'multi' not in sys.argv:
+ maybe_patch_concurrency()
from celery.bin.celery import main as _main
sys.exit(_main())Does this patch also work? Can you try to |
|
yep, i thought the idea was to leave all argv responsibility to click, but this code works. |
Thank you for bringing this to our attention. 😺 I'm going to release a new RC in a few moments. |
Description
eventlet gPidbox is not running in 5.0.0rc1, as described here: #6225
Following the move to Click (https://github.com/celery/celery/pull/5718), I noticed that the patching code was commented out.
I'm not sure if the proposed way is a valid way to port the import patching, or the maintainers had other design in mind, but this fix is working for me.