Skip to content

Commit

Permalink
Object sharer: allow returning of shared objects, cpickle
Browse files Browse the repository at this point in the history
  • Loading branch information
heeres committed Jan 20, 2013
1 parent 5ce7862 commit be77f09
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion source/lib/network/object_sharer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

import logging
import pickle
try:
import cPickle as pickle
except:
import pickle
import socket
from lib.network import tcpserver
import copy
import random
import inspect
import time
import gobject
import types

PORT = 12002
BUFSIZE = 8192
Expand Down Expand Up @@ -313,8 +317,15 @@ def handle_packet(self, conn, packet):
if callid not in self._return_cbs:
logging.warning('Return received for unknown call %d', callid)
return

func = self._return_cbs[callid]
del self._return_cbs[callid]

if type(callinfo) == types.StringType and callinfo.startswith('sharedname:'):
sn = callinfo[11:]
logging.debug('Received shared object reference, finding %s', sn)
callinfo = helper.find_object(sn)

func(callinfo)
return

Expand Down Expand Up @@ -342,6 +353,11 @@ def handle_packet(self, conn, packet):
# No need to send return
return

if isinstance(ret, SharedObject):
sn = root.get_instance_name() + ':' + ret.get_shared_name()
logging.debug('Returning a shared object reference: %s', sn)
ret = 'sharedname:' + sn

self._send_return(conn, info[1], ret)

def _do_send_raw(self, conn, data):
Expand Down Expand Up @@ -712,6 +728,7 @@ def get_object(self, objname):
'properties': props,
'functions': funcs
}

return info

def receive_signal(self, objname, signame, *args, **kwargs):
Expand Down

0 comments on commit be77f09

Please sign in to comment.