Comments (24)
(from @rfk )
I see a similar hang when trying to run the tests from tokenserver
master, and it appears to be caused by gevent monkey-patching. I don't
know exactly how or why. But doing this makes all the tests pass
reliably without hanging for me:
./bin/pip uninstall gevent
Reinstalling gevent brings back the hang.
Both tokenserver and circus do an unconditional monkeypatch if gevent is
available, along the lines of:
try:
from gevent import monkey
from gevent_zeromq import monkey_patch
monkey.patch_all()
monkey_patch()
except ImportError:
pass
I think we should consider doing it only if something else (e.g. the
gunicorn worker code) has already initiated a monkeypath, something like:
if "gevent.monkey" in sys.modules:
try:
from gevent import monkey
from gevent_zeromq import monkey_patch
monkey.patch_all()
monkey_patch()
except ImportError:
pass
Cheers,
Ryan
from tokenserver.
(from @tarekziade )
On 7/17/12 9:22 AM, Ryan Kelly wrote:
I see a similar hang when trying to run the tests from tokenserver
master, and it appears to be caused by gevent monkey-patching. I
don't know exactly how or why. But doing this makes all the tests
pass reliably without hanging for me:./bin/pip uninstall gevent
Reinstalling gevent brings back the hang.
the hang is generally happening because pyzmq uses sockets in a way
that's not compatible with the gevent sockets.
gevent_zmq solves this by making pyzmq green. The usual issue is that
the zmq patching occurs after a pyzmq context was created.
I suspect a bad nose import order, will try to reproduce.
Both tokenserver and circus do an unconditional monkeypatch if gevent
is available, along the lines of:try: from gevent import monkey from gevent_zeromq import monkey_patch monkey.patch_all() monkey_patch() except ImportError: pass
I think we should consider doing it only if something else (e.g. the
gunicorn worker code) has already initiated a monkeypath, something like:
I don't understand why you want to patch again only if gevent was
already patched.
The thing is, if gevent is installed, we don't know how the code will
use it and potentially lock everything, so we do need to monkey patch
Will have a look, cheers
from tokenserver.
(from @rfk )
Hmmm, right, I guess when you put it like that it doesn't make much
sense :-)
What I'm trying to suggest is that we somehow detect that gevent
monkeypatching is already in place, and if it is, then do the necessary
extra gevent_zeromq monkeypatching as well:
if GEVENT_IS_ALREADY_MONKEYPATCHED:
from gevent_zeromq import monkey_patch
monkey_patch()
Ideally this code would live inside pyzmq itself, so that pyzmq Just
Works when gevent monkey-patching is in place.
The thing is, if gevent is installed, we don't know how the code will
use it and potentially lock everything, so we do need to monkey patch
We don't know whether the code will use it.
If the calling code uses gevent and we don't monkey-patch then we'll get
hangs. But conversely, if the calling code doesn't use gevent and we do
monkey-patch then we can get hangs like seen here.
So I feel like there's something a little more nuanced that we can do to
work well in both situations. The "if 'gevent.monkey' in sys.modules"
thing is just one suggestion.
from tokenserver.
(from @tarekziade )
We don't know whether the code will use it.
If the calling code uses gevent and we don't monkey-patch then we'll
get hangs. But conversely, if the calling code doesn't use gevent and
we do monkey-patch then we can get hangs like seen here.
That's the part I don't agree with => if the calling code doesn't use
gevent and we do monkey-patch then we can get hangs like seen here.
I think it's rather => If gevent and pyzmq are both present, make sure
both are patched before any one of them is ever used.
So I feel like there's something a little more nuanced that we can do
to work well in both situations. The "if 'gevent.monkey' in
sys.modules" thing is just one suggestion.
Unfortunately that does not really prove gevent monkey patch was or was
not called -- just imported . Even if it's called, we don't know if the
socket module was patched or not.
Cheers
from tokenserver.
Errors and traceback reproduced on all of the clientX boxes this morning.
So at least the errors I see are consistent.
from tokenserver.
(per tarek)
I moved lib/python2.6/site-packages/gevent_z* in the tokenserver directory (after doing make build)
$ git clone git://github.com/mozilla-services/tokenserver
$ cd tokenserver
$ make build
$ mv lib/python2.6/site-packages/gevent_zeromq-0.2.2-py2.6.egg lib/python2.6/site-packages/gevent_zeromq-0.2.2-py2.6.egg-SAVE
(or similar)
$ make test
All functional tests passed.
So, we have a workaround.
from tokenserver.
OK, so on Mac install:
Workaround:
$ mv lib/python2.7/site-packages/gevent_zeromq-0.2.2-py2.7-macosx-10.7-intel.egg lib/python2.7/site-packages/gevent_zeromq-0.2.2-py2.7-macosx-10.7-intel.egg-SAVE
$ ls -al lib/python2.7/site-packages/gevent*
lib/python2.7/site-packages/gevent-0.13.7-py2.7-macosx-10.7-intel.egg:
lib/python2.7/site-packages/gevent_zeromq-0.2.2-py2.7-macosx-10.7-intel.egg-SAVE:
Still fails, but does not hang: http://jbonacci.pastebin.mozilla.org/1713799
from tokenserver.
@jbonacci The "AttributeError: Socket has no such option: HWM" might mean that you have the wrong version of zmq installed on your system, thus the failures
from tokenserver.
ok please try again on a fresh master
$ make build test
from tokenserver.
This is the latest from qa2 (rhel6) and client4 (rhel6):
FAIL: test_ttled_dict (tokenserver.tests.test_crypto_pyworker.TestTTledDict)
Traceback (most recent call last):
File "/opt/tokenserver/tokenserver/tokenserver/tests/test_crypto_pyworker.py", line 128, in test_ttled_dict
self.assertFalse('foo' in cache)
AssertionError: True is not False
Ran 25 tests in 17.194s
FAILED (failures=1)
make: *** [test] Error 1
from tokenserver.
On Mac, still getting this issue: http://jbonacci.pastebin.mozilla.org/1715031
(not really sure full functionality on Mac is that important)
from tokenserver.
@jbonacci you did not fix your zmq / pyzmq mismatch : AttributeError: Socket has no such option: HWM
from tokenserver.
it's working for me on OS X
from tokenserver.
OK, once I "downgraded" libzmq from 3.3 to 2.2, the functional tests started working - no errors on Mac.
Ran 25 tests in 14.245s
OK
So, on Linux, I still see the one error above:
#12 (comment)
from tokenserver.
@tarekziade if you are ok with the one error on Linux, we can close this issue.
Otherwise, let me know what other tests, steps, information you need from me.
from tokenserver.
@jbonacci it would be great if you can pick this up and see what the current status is on various platforms. Updated versions of our dependencies may have made the situation better, or worse :-)
from tokenserver.
@rfk
Wow, a blast from the past!
Sure, if you can tell me the correct values for this:
$ make build CHANNEL=prod TOKENSERVER=rpm-0.8.2
from tokenserver.
Let's forget about channels for now, and just see where we're at with a vanilla make build
.
from tokenserver.
Ran into some external dependency issues on Mac - will assume same for Linux.
Checking other OS just to see what errors come up...
from tokenserver.
Not sure if it will help you, but here are some "make build" failure snapshots:
Mac: https://jbonacci.pastebin.mozilla.org/3954804
Ubuntu 13: https://jbonacci.pastebin.mozilla.org/3955504
CentOS: https://jbonacci.pastebin.mozilla.org/3955803
RHEL AWS: https://jbonacci.pastebin.mozilla.org/3955165
Ubuntu AWS: https://jbonacci.pastebin.mozilla.org/3955009
from tokenserver.
@jbonacci the deps have been updated, you should have more luck with the builds now.
from tokenserver.
OK. As you know, I got Mac to build.
Still tinkering with AWS (rhel and ubuntu) - issues have come up around the following
memcached
libmemcached
libevent-dev
from tokenserver.
OK. I got this to "make build" twice (two different Macs).
I had to pre-install libmemcached (but not memcached directly) and easy_install.
...etc...
Building the app
Checking the environ [ok]
Updating the repo [ok]
Building Services dependencies [ok]
Building External dependencies [ok]
Now building the app itself [ok]
[done]
from tokenserver.
OK, so I can run unit test on the following:
Mac
AWS ubuntu
AWS rhel
There are errors of various kinds, but I can open separate issues for each platform if you want...
PS still working on SciLinux...
from tokenserver.
Related Issues (20)
- How to further fix to purge_old_records task (?) HOT 11
- Consider switching UID generation to random number rather than autoincrement value HOT 1
- Convert TokenServer to rust
- Upgrade PyFxA and add tests to confirm that fxa-generation fields are correctly handled. HOT 1
- Cannot build loadtest on 1.5.6 HOT 3
- Cannot start 1.5.6 docker container (ContextualVersionConflict cffi) HOT 11
- CryptographyDeprecationWarning for openssl
- Create a new release with only the pypy upgrade HOT 6
- Figure out caching story for OAuth JWK request HOT 2
- Use sane metric library HOT 1
- Browser id removal - confirm what caused the CPU spike. HOT 2
- Figure out how to include JWT OAuth tokens in the loadtest
- Modify CircleCI config to avoid rate limiting. HOT 1
- Allow specifying the Makefile's python interpreter
- Add Sentry Configuration HOT 2
- Upgrade docker to debian buster
- Travis CI free usage ends Dec 3; mozilla repos should switch to other CI platforms
- Update requirement for Python 3.10
- Makefile:40: local/.install.stamp] Error 137
- how to run docker mozilla/tokenserver?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokenserver.