commit 74dad390c9b525bbf4373132b7f6ae34bd99261f
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Fri Apr 12 12:20:01 2013 +0200
ConnectionHandler: adjust send and recv functions
When using the Connection object for communication it is unnecessary to
pickle our data as this is automatically handled by the Connection
object.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
lnst/Common/ConnectionHandler.py | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/lnst/Common/ConnectionHandler.py b/lnst/Common/ConnectionHandler.py
index eb80055..8e9e548 100644
--- a/lnst/Common/ConnectionHandler.py
+++ b/lnst/Common/ConnectionHandler.py
@@ -17,16 +17,15 @@ import socket
from _multiprocessing import Connection
def send_data(s, data):
- pickled_data = cPickle.dumps(data)
- length = len(pickled_data)
-
- data_to_send = str(length) + " " + pickled_data
-
try:
if isinstance(s, socket.SocketType):
+ pickled_data = cPickle.dumps(data)
+ length = len(pickled_data)
+
+ data_to_send = str(length) + " " + pickled_data
s.sendall(data_to_send)
elif isinstance(s, Connection):
- s.send(pickled_data)
+ s.send(data)
else:
return False
except socket.error:
@@ -57,7 +56,6 @@ def recv_data(s):
data = cPickle.loads(data)
elif isinstance(s, Connection):
data = s.recv()
- data = cPickle.loads(data)
else:
return None
return data
Show replies by date