git » pymisc » master » tree

[master] / samples / pickle_rpc / s1.py

import pickle_rpc

def f(*args, **kwargs):
	print 'F!', args, kwargs
	return ('Go!', args, kwargs)

def exc():
	raise KeyError, 'No no no'

def long(n):
	l = []
	for i in range(n):
		l.append((i, i + 1, i + 2, i + 3))
	return l


class Test1:
	def __init__(self, n):
		self.n = n

	def method(self, *args):
		return (self.n, args)

class Test2:
	def __init__(self, t1):
		self.t1 = t1


srv = pickle_rpc.Server('localhost')
srv.register(f)
srv.register(exc)
srv.register(long)
srv.register_object("test2_i", Test2(Test1("inst1")))
srv.loop()