From b0ad6eadf0986bfa89c1ab71461dc446ba5d9ae4 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Tue, 10 Apr 2012 10:49:20 -0700 Subject: [PATCH] Import _strptime early to avoid errors on import in threads. --- r2/r2/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/r2/r2/__init__.py b/r2/r2/__init__.py index 0bc6cb0cb..dade0c705 100644 --- a/r2/r2/__init__.py +++ b/r2/r2/__init__.py @@ -24,6 +24,13 @@ This file loads the finished app from r2.config.middleware. """ +# _strptime is imported with PyImport_ImportModuleNoBlock which can fail +# miserably when multiple threads try to import it simultaneously. +# import this here to get it over with +# see "Non Blocking Module Imports" in: +# http://code.google.com/p/modwsgi/wiki/ApplicationIssues +import _strptime + # defer the (hefty) import until it's actually needed. this allows # modules below r2 to be imported before cython files are built, also # provides a hefty speed boost to said imports when they don't need