Hi!
I can't figure out how to use Perspective broker over stdio. Say I have
file `child.py`:
----
from twisted.internet.endpoints import StandardIOEndpoint
from twisted.internet import reactor
from twisted.spread import pb
class Foo(pb.Root):
def remote_do_smth(self):
pass
def main():
endpoint = StandardIOEndpoint(reactor)
f = pb.PBServerFactory(Foo())
endpoint.listen(f)
reactor.run()
if __name__ == '__main__':
main()
----
Then say I have `main.py`:
----
import sys
from twisted.spread import pb
from twisted.internet import reactor
def cb(o):
d = o.callRemote("do_smth")
return d
def main():
exe = sys.executable
args = [exe, '/path/to/child.py']
factory = pb.PBClientFactory()
# now what? The below is a wrong way to create protocol.
# But how do I do this?
proto = factory.buildProtocol(('foo',))
reactor.spawnProcess(proto, exe, args)
d = factory.getRootObject()
d.addCallback(cb)
d.addCallback(lambda _: reactor.stop())
reactor.run()
if __name__ == '__main__':
main()
----
How do I spawn `child.py` from a parent process, such that the parent can
retrieve the root object and call methods on it?
The code above throws errors:
http://pastebin.com/7TiZdDVc
Thanks in advance.
--
Regards,
Maxim
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python