AppRegistryNotReady error running fastcgi on IIS

260 views
Skip to first unread message

Shawn H

unread,
Sep 26, 2014, 11:26:35 AM9/26/14
to django...@googlegroups.com
So I have a project running at version 1.6 fine on IIS. I switch it to use 1.7, and it quits working. Specifically, it's trying to translate something using ugettext, but it's not in my code. It seems to be trying to translate something using dateformat.py from django. I don't understand what's going on, because when I run the exact same code through Aptana (so NOT IIS) it runs fine (again, using django 1.7) I thought maybe it was the fcgi script causing the problem, so I entered import django and django.setup() at the top of that file before calling runfastcgi, but that didn't resolve the issue. In my settings.py I'm doing two translations, but I am using ugettext_lazy in that file, and I commented that section out and that didn't resolve it either. What could be going on? I've copied the entire error traceback below. Thanks.



Error occurred: Traceback (most recent call last): File "C:\Python27\Scripts\wfastcgi.py", line 736, in main result = handler(record.params, response.start) File "C:\Virtual\Django17\lib\site-packages\django\core\handlers\wsgi.py", line 187, in __call__ response = self.get_response(request) File "C:\Virtual\Django17\lib\site-packages\django\core\handlers\base.py", line 199, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "C:\Virtual\Django17\lib\site-packages\django\core\handlers\base.py", line 236, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "C:\Virtual\Django17\lib\site-packages\django\views\debug.py", line 91, in technical_500_response html = reporter.get_traceback_html() File "C:\Virtual\Django17\lib\site-packages\django\views\debug.py", line 350, in get_traceback_html return t.render(c) File "C:\Virtual\Django17\lib\site-packages\django\template\base.py", line 148, in render return self._render(context) File "C:\Virtual\Django17\lib\site-packages\django\template\base.py", line 142, in _render return self.nodelist.render(context) File "C:\Virtual\Django17\lib\site-packages\django\template\base.py", line 844, in render bit = self.render_node(node, context) File "C:\Virtual\Django17\lib\site-packages\django\template\debug.py", line 80, in render_node return node.render(context) File "C:\Virtual\Django17\lib\site-packages\django\template\debug.py", line 90, in render output = self.filter_expression.resolve(context) File "C:\Virtual\Django17\lib\site-packages\django\template\base.py", line 624, in resolve new_obj = func(obj, *arg_vals) File "C:\Virtual\Django17\lib\site-packages\django\template\defaultfilters.py", line 769, in date return format(value, arg) File "C:\Virtual\Django17\lib\site-packages\django\utils\dateformat.py", line 343, in format return df.format(format_string) File "C:\Virtual\Django17\lib\site-packages\django\utils\dateformat.py", line 35, in format pieces.append(force_text(getattr(self, piece)())) File "C:\Virtual\Django17\lib\site-packages\django\utils\dateformat.py", line 268, in r return self.format('D, j M Y H:i:s O') File "C:\Virtual\Django17\lib\site-packages\django\utils\dateformat.py", line 35, in format pieces.append(force_text(getattr(self, piece)())) File "C:\Virtual\Django17\lib\site-packages\django\utils\encoding.py", line 85, in force_text s = six.text_type(s) File "C:\Virtual\Django17\lib\site-packages\django\utils\functional.py", line 144, in __text_cast return func(*self.__args, **self.__kw) File "C:\Virtual\Django17\lib\site-packages\django\utils\translation\__init__.py", line 83, in ugettext return _trans.ugettext(message) File "C:\Virtual\Django17\lib\site-packages\django\utils\translation\trans_real.py", line 325, in ugettext return do_translate(message, 'ugettext') File "C:\Virtual\Django17\lib\site-packages\django\utils\translation\trans_real.py", line 306, in do_translate _default = translation(settings.LANGUAGE_CODE) File "C:\Virtual\Django17\lib\site-packages\django\utils\translation\trans_real.py", line 209, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "C:\Virtual\Django17\lib\site-packages\django\utils\translation\trans_real.py", line 189, in _fetch "The translation infrastructure cannot be initialized before the " AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time. StdOut: StdErr: 


Collin Anderson

unread,
Sep 29, 2014, 3:38:38 PM9/29/14
to django...@googlegroups.com
Are you sure you're calling django.setup() before the first request happens?

From what I can tell, an error happens while processing a request, and then this error happens while trying to generate a pretty error message.

Shawn H

unread,
Sep 29, 2014, 4:00:10 PM9/29/14
to django...@googlegroups.com
I was, but it turns out that wasn't the issue. I asked the question on the pytools site (here), thinking it was possible an issue with wfastcgi. It turns out it's not an issue with wfastcgi. It's that At 1.6, the recommended handler was 

django.core.handlers.wsgi.WSGIHandler()

At 1.7, it seems the correct handler is now

django.core.wsgi.get_wsgi_application()

which calls django.setup() directly.

As soon as I replaced my handler in my web.config file, the issue disappeared. As you can see at the issue on the pytools site, there is still plenty of confusion as to the proper way to use wfastcgi in a pure wsgi application, but at least I can run my application. Thanks.
Reply all
Reply to author
Forward
0 new messages