conduit r1399 - trunk/conduit/modules/NetworkModule
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1399 - trunk/conduit/modules/NetworkModule
- Date: Fri, 28 Mar 2008 10:18:49 +0000 (GMT)
Author: jstowers
Date: Fri Mar 28 10:18:49 2008
New Revision: 1399
URL: http://svn.gnome.org/viewvc/conduit?rev=1399&view=rev
Log:
2008-03-28 John Stowers <john stowers gmail com>
* conduit/modules/NetworkModule/XMLRPCUtils.py: Use cPickle instead
of pickle. Improves network sync performance, but we still use too much
memory.
Modified:
trunk/conduit/modules/NetworkModule/XMLRPCUtils.py
Modified: trunk/conduit/modules/NetworkModule/XMLRPCUtils.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/XMLRPCUtils.py (original)
+++ trunk/conduit/modules/NetworkModule/XMLRPCUtils.py Fri Mar 28 10:18:49 2008
@@ -8,7 +8,7 @@
import select
import traceback
import threading
-import pickle
+import cPickle
import xmlrpclib
import SimpleXMLRPCServer
import logging
@@ -53,6 +53,14 @@
else:
raise xmlrpclib.Fault("Exception",traceback.format_exc())
+def pickle_obj_to_binary(obj):
+ bin = xmlrpclib.Binary(cPickle.dumps(obj))
+ return bin
+
+def unpickle_obj_from_binary(bin):
+ obj = cPickle.loads(bin.data)
+ return obj
+
class StoppableXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
"""
A variant of SimpleXMLRPCServer that can be stopped. From
@@ -129,17 +137,17 @@
DataProvider.TwoWay.get(self, LUID)
try:
binaryData = self.server.get(LUID)
- return pickle.loads(binaryData.data)
+ return unpickle_obj_from_binary(binaryData)
except xmlrpclib.Fault, f:
marshal_fault_to_exception(f)
@Utils.log_function_call(clog)
def put(self, data, overwrite=False, LUID=None):
DataProvider.TwoWay.put(self, data, overwrite, LUID)
- binaryData = xmlrpclib.Binary(pickle.dumps(data))
+ binaryData = pickle_obj_to_binary(data)
try:
binaryRid = self.server.put(binaryData, overwrite, LUID)
- return pickle.loads(binaryRid.data)
+ return unpickle_obj_from_binary(binaryRid)
except xmlrpclib.Fault, f:
#Supply additional info because the conflict exception
#includes details of the conflict
@@ -249,16 +257,16 @@
@Utils.log_function_call(slog)
def get(self, LUID):
try:
- return xmlrpclib.Binary(pickle.dumps(self.dpw.module.get(LUID)))
+ return pickle_obj_to_binary(self.dpw.module.get(LUID))
except Exception, e:
return marshal_exception_to_fault(e)
@Utils.log_function_call(slog)
def put(self, binaryData, overwrite, LUID):
- data = pickle.loads(binaryData.data)
+ data = unpickle_obj_from_binary(binaryData)
try:
rid = self.dpw.module.put(data, overwrite, LUID)
- return xmlrpclib.Binary(pickle.dumps(rid))
+ return pickle_obj_to_binary(rid)
except Exception, e:
return marshal_exception_to_fault(e)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]