Hi folks

Hoping someone can help with this, I'm looking to run a rpyc server in 
a separate thread within an application (specifically autodesk maya) 
and communicate with it from an external python interpreter running the 
client, utilizing the rpycs conn.modules proxy feature

The problem a lot of the apps commands that need to be run on the server 
thread are not thread safe

In order to get around this problem I would need to inject the command 
below somewhere into rpyc command execution pipe.
executeInMainThreadWithResult(x, *p, **kw)

In essence i want to replace the following SimpleXmlRpc I'm currently using 
with a more generic rpyc approach

import thread
from SimpleXMLRPCServer import *
from maya.utils import *


class mainThreadHandler(SimpleXMLRPCRequestHandler):
    def _dispatch(self, method, params):
        x = getattr(cmds,method)
        kw = {}
        p = []
        for n in params:
            if (isinstance(n, type({}))):
                kw = n
            else:
                p.append(n)
        p = tuple(p)
        y =  executeInMainThreadWithResult(x, *p, **kw)

        return y
    def log_message(self, format, *args):
        print format % args

def dispatchForever(x):
    server = SimpleXMLRPCServer(("127.0.0.1", 18999), mainThreadHandler, 
allow_none=1)
    print "registering"
    for n in dir(cmds):
        xx= getattr(cmds, n)
        if (callable(xx)):
            server.register_function(getattr(cmds, n))
    print "registering complete, serving"
    server.serve_forever()
thread.start_new_thread(dispatchForever, (None,))


Any ideas?
Cheers
Nick

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"rpyc" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to