[cpif] r24 - trunk
svn at argo.es
svn at argo.es
Thu Apr 26 20:43:48 CEST 2007
Author: jcea
Date: Thu Apr 26 20:43:47 2007
New Revision: 24
Log:
Aun mas compatibilidad windowsi (y 2 :)
Modified:
trunk/storage.py
Modified: trunk/storage.py
==============================================================================
--- trunk/storage.py (original)
+++ trunk/storage.py Thu Apr 26 20:43:47 2007
@@ -8,10 +8,10 @@
# de persistencia con acceso via unix socket
def storage(path) :
- try :
+ if os.name != 'nt' : # De momento mi libreria no va en Windows...
import berkeleydb_storage
st=berkeleydb_storage.BerkeleyDBStorage(path,do_recover=True,durable=False,async_log_write=True)
- except :
+ else :
print >>sys.stderr,"ATENCION: Usando el backend durus normal..."
from durus.file_storage import FileStorage
st=FileStorage(os.path.join(path,"db.durus"))
@@ -27,21 +27,34 @@
import os
os._exit(os.EX_OK)
+ def conn_constructor() :
+ from durus.client_storage import ClientStorage
+ from durus.connection import Connection
+
+ conn= Connection(ClientStorage(address=path))
+ return conn
+
if os.name == 'nt' : # En windows no hay sockets unix...
path=("127.0.0.1",7911)
+
+ def storage_background(storage,path) :
+ storage_background.storage=storage
+ import time
+ while True :
+ time.sleep(0.1)
+
+ def conn_constructor() :
+ from durus.connection import Connection
+ conn=Connection(storage_background.storage)
+ storage_background.storage=None # En esta modalidad, solo permitimos una conexion
+ return conn
+
else :
path=os.path.join(path,"unix_socket")
import threading
storage_thread=threading.Thread(target=storage_background,args=(st,path))
storage_thread.setDaemon(True)
storage_thread.start()
-
- def conn_constructor() :
- from durus.client_storage import ClientStorage
- from durus.connection import Connection
-
- conn= Connection(ClientStorage(address=path))
- return conn
return storage_thread,conn_constructor
More information about the cpif
mailing list