Reputation: 1741
As explained here, redirecting the stdio/stdin is very simple with RPyC 2. This means that 'print' commands executed in the server, will display the printed string on the client side.
RPyC 2, as explained here, is un-secured and is not recommended, but I couldn't find anywhere how can I print on the client side with RPyC 3.
Does anyone know how to achieve this?
Edit:
For example, this is the code to my server:
import rpyc
import time
from rpyc.utils.server import ThreadedServer
class TimeService(rpyc.Service):
def exposed_print_time(self):
for i in xrange(10):
print time.ctime()
time.sleep(1)
if __name__ == "__main__":
t = ThreadedServer(TimeService, port=8000)
t.start()
and in my client, I run:
conn = rpyc.connect("192.168.1.5")
conn.root.print_time()
my goal is to get the time every second (or anything else I want to print) in the client's stdout, but the client just hangs and the time is only printed in the server.
Upvotes: 0
Views: 658
Reputation: 41
you could use return on server side:
#on server
def exposed_test(self):
return "this is test"
#on client
conn.root.test()
>>> 'this is test'
Upvotes: 0