Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check uwsgi options #148

Merged
merged 1 commit into from
Nov 25, 2020
Merged

Fix check uwsgi options #148

merged 1 commit into from
Nov 25, 2020

Conversation

andrefreitas
Copy link
Contributor

Even if uwsgi is avaiable in sys.modules, you need to check if uwsgi.opt is available. This code was broken in latest version of uwsgi when running a process without uwsgi. The uwsgi documentation unfortunately is not clear about this https://uwsgi-docs.readthedocs.io/en/latest/PythonModule.html

Also the link for LaunchDarkly documentation is broken.

@eli-darkly
Copy link
Contributor

Can you say a bit more about how you discovered this behavior? The uwsgi documentation indeed doesn't seem to say anything at all about a circumstance in which uwsgi would be present but uwsgi.opt wouldn't, and I haven't found anything in the uwsgi release notes to indicate when (or why) this behavior changed. I don't see any harm in adding this extra check, since we don't want to throw an error due to uwsgi.opt being missing if it is missing, but I'd like to understand what this would actually mean.

ldclient/util.py Outdated Show resolved Hide resolved
Even if uwsgi is avaiable in sys.modules, you need to check if uwsgi.opt
is available. This code was broken in latest version of uwsgi when
running a process without uwsgi. The uwsgi documentation unfortunately is not clear about this https://uwsgi-docs.readthedocs.io/en/latest/PythonModule.html

Also the link for LaunchDarkly documentation is broken.
@andrefreitas
Copy link
Contributor Author

@eli-darkly thanks for your prompt feedback. I also don't understand from uWSGI documentation unfortunately. We detected this issue running LaunchDarkly under RQ.

For the sake of checking if this is the "normal" behaviour, I created a simple http server that runs with and without uWSGI and tried to use the ld client and import uWSGI, and when it doesn't run under uWSGI the import fails as the documentation say: https://github.com/andrefreitas/test-uwsgi

flask_1  | [2020-11-25 15:43:30,852] ERROR in app: Exception on / [GET]
flask_1  | Traceback (most recent call last):
flask_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
flask_1  |     response = self.full_dispatch_request()
flask_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
flask_1  |     rv = self.handle_user_exception(e)
flask_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
flask_1  |     reraise(exc_type, exc_value, tb)
flask_1  |   File "/usr/local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
flask_1  |     raise value
flask_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
flask_1  |     rv = self.dispatch_request()
flask_1  |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
flask_1  |     return self.view_functions[rule.endpoint](**req.view_args)
flask_1  |   File "/app/server.py", line 12, in index
flask_1  |     import uwsgi # fails in flask
flask_1  | ModuleNotFoundError: No module named 'uwsgi'

I don't like not understanding why rq changes this, but I also see that adding this extra check doesn't produce any harm, so I am fine with the tradeoff of not understanding fully at this moment the root cause.

So are you fine in proceeding like this?

@eli-darkly
Copy link
Contributor

@andrefreitas Yes, I agree that there's no harm in the extra check. I was just hoping to be able to write a release note that was a little more specific about what circumstances this might apply to, but I guess the note will have to be somewhat vague.

Copy link
Contributor

@eli-darkly eli-darkly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and addressing these issues.

@eli-darkly eli-darkly merged commit e6219c9 into launchdarkly:master Nov 25, 2020
@eli-darkly
Copy link
Contributor

We've released version 7.0.1 which includes this fix.

@andrefreitas andrefreitas deleted the fix-check-uwsgi branch November 26, 2020 10:52
@andrefreitas
Copy link
Contributor Author

@eli-darkly me and the Beyond Pricing engineering team appreciate your collaboration. Thanks 🙏

LaunchDarklyReleaseBot pushed a commit that referenced this pull request Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants