From 5ec0c392d34df5ee5105c80a611d767ce80fac32 Mon Sep 17 00:00:00 2001 From: Tyson Clugg Date: Thu, 5 Nov 2015 14:42:24 +1100 Subject: [PATCH] Fix order of `psycopg2cffi.compat.register()` call and `psycogreen.gevent.patch_psycopg()` call, demote threading module exception to warning. --- dddp/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dddp/__init__.py b/dddp/__init__.py index 43f52f0..b031b85 100644 --- a/dddp/__init__.py +++ b/dddp/__init__.py @@ -25,12 +25,10 @@ def greenify(): from gevent.monkey import patch_all, saved if ('threading' in sys.modules) and ('threading' not in saved): - raise Exception('threading module loaded before patching!') + import warnings + warnings.warn('threading module loaded before patching!') patch_all() - from psycogreen.gevent import patch_psycopg - patch_psycopg() - try: # Use psycopg2 by default import psycopg2 @@ -40,6 +38,9 @@ def greenify(): from psycopg2cffi import compat compat.register() + from psycogreen.gevent import patch_psycopg + patch_psycopg() + class AlreadyRegistered(Exception):