def setUp(self): green_env = 'eventlet' Context, _ = get_zmq_classes(env=green_env) self.context = Context() self.client = GreenRPCClient(context=self.context, green_env=green_env) self.service = GreenRPCService(context=self.context, green_env=green_env) super(EventletBase, self).setUp()
class EventletBase(BaseCase): def setUp(self): green_env = 'eventlet' Context, _ = get_zmq_classes(env=green_env) self.context = Context() self.client = GreenRPCClient(context=self.context, green_env=green_env) self.service = GreenRPCService(context=self.context, green_env=green_env) super(EventletBase, self).setUp() def tearDown(self): self.client.shutdown() self.service.shutdown() self.context.term() super(EventletBase, self).tearDown()
def setUp(self): env = 'greenhouse' Context, _ = get_zmq_classes(env) self.tools = get_tools(env) self.context = Context() self.executor = self.tools.Executor(24) self.client = GreenRPCClient(context=self.context, green_env=env, executor=self.executor) self.service = GreenRPCService(context=self.context, green_env=env, executor=self.executor) super(GreenhouseBase, self).setUp()
class GeventBase(BaseCase): def setUp(self): env = "gevent" Context, _ = get_zmq_classes(env) self.tools = get_tools(env) self.context = Context() self.executor = self.tools.Executor(24) self.client = GreenRPCClient(context=self.context, green_env=env, executor=self.executor) self.service = GreenRPCService(context=self.context, green_env=env, executor=self.executor) super(GeventBase, self).setUp() def tearDown(self): self.client.shutdown() self.service.shutdown() self.context.term() self.executor.shutdown(cancel=True) super(GeventBase, self).tearDown()
def printer(msg, func, *args): "run a function, print results" print msg, '<request>' res = func(*args) print msg, '<response>', res if __name__ == '__main__': #from netcall import setup_logger #setup_logger() # Custom serializer/deserializer functions can be passed in. The server # side ones must match. echo = GreenRPCClient(green_env='eventlet', serializer=JSONSerializer()) echo.connect('tcp://127.0.0.1:5555') tasks = GreenPool() spawn = tasks.spawn spawn(printer, "[echo] Echoing \"Hi there\"", echo.echo, "Hi there") try: print "Testing a remote exception...", echo.error() print "FAIL, no remote exception!" except RemoteRPCError, e: print "OK, got an expected remote exception:" #print e.ename print e.evalue
from gevent.pool import Group from netcall.green import GreenRPCClient, RemoteRPCError, RPCTimeoutError, JSONSerializer def printer(msg, func, *args): "run a function, print results" print msg, '<request>' res = func(*args) print msg, '<response>', res if __name__ == '__main__': #from netcall import setup_logger #setup_logger() # Custom serializer/deserializer functions can be passed in. The server # side ones must match. echo = GreenRPCClient(green_env='gevent', serializer=JSONSerializer()) echo.connect('tcp://127.0.0.1:5555') tasks = Group() spawn = tasks.spawn spawn(printer, "[echo] Echoing \"Hi there\"", echo.echo, "Hi there") try: print "Testing a remote exception...", echo.error() print "FAIL, no remote exception!" except RemoteRPCError, e: print "OK, got an expected remote exception:" #print e.ename print e.evalue