[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [pytorctl/master] Only require sqlalchemy if we really need it.



Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Sun, 3 Oct 2010 14:21:22 -0700
Subject: Only require sqlalchemy if we really need it.
Commit: e7610e7c0e4659b9f60b5b1ef106e33b7d7b675b

---
 ScanSupport.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ScanSupport.py b/ScanSupport.py
index 3852afc..629adce 100644
--- a/ScanSupport.py
+++ b/ScanSupport.py
@@ -1,12 +1,14 @@
 import PathSupport
-import SQLSupport
 import threading
 import copy
 import time
 import shutil
+import TorCtl
 
 from TorUtil import plog
 
+SQLSupport = None
+
 # Note: be careful writing functions for this class. Remember that
 # the PathBuilder has its own thread that it recieves events on
 # independent from your thread that calls into here.
@@ -169,6 +171,14 @@ class ScanHandler(PathSupport.PathBuilder):
     cond.release()
 
 class SQLScanHandler(ScanHandler):
+  def __init__(self, c, selmgr, RouterClass=TorCtl.Router,
+               strm_selector=PathSupport.StreamSelector):
+    # Only require sqlalchemy if we really need it.
+    global SQLSupport
+    if SQLSupport is None:
+      import SQLSupport
+    ScanHandler.__init__(self, c, selmgr, RouterClass, strm_selector)
+
   def attach_sql_listener(self, db_uri):
     plog("DEBUG", "Got sqlite: "+db_uri)
     SQLSupport.setup_db(db_uri, echo=False, drop=True)
-- 
1.7.1