+++ /dev/null
-import time\r
-from Rpyc.Factories import SocketConnection, Async\r
-\r
-c = SocketConnection("localhost")\r
-c2 = SocketConnection("localhost")\r
-\r
-huge_xml = "<blah a='5' b='6'> " * 50000 + " </blah> " * 50000\r
-parseString = Async(c.modules.xml.dom.minidom.parseString)\r
-res = parseString(huge_xml)\r
-\r
-print "while we're waiting for the server to complete, we do other stuff"\r
-t = time.time()\r
-while not res.is_ready:\r
- time.sleep(0.5)\r
- # we dont want to use `c`, because it would block us (as the server is blocking)\r
- # but `c2` runs on another thread/process, so it wouldn't block\r
- print c2.modules.os.getpid()\r
-\r
-t = time.time() - t\r
-print "it took %d seconds" % (t,)\r
-\r
-print res.result\r
-\r
-\r
-#\r
-# note: to improve performance, delete the result when you no longer need it.\r
-# this should be done because the server might (as in this case) hold enormous \r
-# amounts of memory, which will slow it down\r
-#\r
-# if you do this:\r
-# res = parseString(huge_xml)\r
-# res = parseString(huge_xml)\r
-# res will be deleted only after the second operation finishes, because only when\r
-# the second result is assigned, the first is released -- server still holds \r
-# around 160MB of the old xml tree for nothing. so it's a good idea to `del res` \r
-# when you dont need it.\r
-#\r
-# also, there's a memory leak on the server, which i'm working on solving.\r
-#\r
-\r
-\r