Kazoo deadlock with uWSGI and Upstart

134 views
Skip to first unread message

q4brk

unread,
Jul 1, 2014, 6:57:57 AM7/1/14
to pyth...@googlegroups.com
Hi,

Can anybody take a look at this thread on uWSGI's mailing list: http://lists.unbit.it/pipermail/uwsgi/2014-July/007461.html and see if it's a problem with Kazoo or something else? 

I'm going to summarise the findings: 

When running a simple test app (uWSGI+Bottle+Kazoo) with Upstart, the environment variable LANG doesn't get set by default and this causes problems for Kazoo in this setup. What the app does is initialise the logging system on DEBUG, create a zookeeper client and set a DataWatch to monitor a key; afterwards it just replies to http requests on "/ping" to test if it's still alive. 

I've managed to narrow down the problem to the following conditions:

if:
  • app started by Upstart (LANG is not set in the environment)
  • app runs in uWSGI 
  • use a DataWatch with a callback
  • the code: http://pastebin.com/w0B6WMat
then:
  • when the callback should be called, the application deadlocks. 
I've found an issue that is vaguely similar (https://github.com/python-zk/kazoo/issues/187) but wasn't able to reproduce. 


What fixes it:
  • don't run in uWSGI (e.g. use bottle's internal server) OR
  • don't run from Upstart (run directly, LANG will be set) OR
  • run from Upstart and export LANG to the environment

Any idea what's going on? 

Regards,

Matt Wise

unread,
Jul 1, 2014, 10:26:50 AM7/1/14
to q4brk, pyth...@googlegroups.com
Just a quick comment, this has been a long standing issue.. see the note we have in our nd_service_registry code here.

Warning: LC_ALL and LANG settings Due to an unknown bug, if Django cannot find your LC_ALL LOCALE settings (which often default to 'C'), nd_service_registry or kazoo crash and burn during the init phase. Its unknown why at this point, but we've found that its best to unset LC_ALL and set LANG=en_US:UTF-8 (or some other valid setting) before you start up your Django app.
If you use Celery, set these options in /etc/default/celeryd.
If you use uWSGI, set them in your uWSGI config file.
Running the Django shell
# unset LC_ALL; LANG=en_US:UTF-8 python manage.py shell


Matt Wise
Sr. Systems Architect
Nextdoor.com


--
You received this message because you are subscribed to the Google Groups "python-zk" group.
Visit this group at http://groups.google.com/group/python-zk.

Reply all
Reply to author
Forward
0 new messages