On Aug 25, 6:37 pm, Andrew <[EMAIL PROTECTED]> wrote: > Hi I was wondering if there is anyway with XML RPC to send a string of > text from the server to the client with out calling return thus breaking > my loop > > for example > > def somefunc(): > for action, files in results: > full_filename = os.path.join(path_to_watch, files) > theact = ACTIONS.get(action, "Unknown") > out2 = str(full_filename) + " " + str(theact) > return out2 > > the return statement will return a result breaking my loop. My goal is > to have it continue looping and updating the client > > any ideas? > > Cheers > > Andrew > > Thanks in advance > > Pyhon 2.5.2 > > Windows XP
Andrew, I have generators working on both sides of a SimpleXMLRPCServer instance. You ask for a server-side generator, and I won't post the whole program, as it's long, so here's an important part: server = SimpleXMLRPCServer(("localhost", 8000)) server.register_introspection_functions() def gen( ): while 1: yield 1 yield 2 yield 3 servg= gen( ) server.register_function( servg.next, 'gen' ) Called 's.gen( )' four times, output: localhost - - [25/Aug/2008 23:08:28] "POST /RPC2 HTTP/1.0" 200 - 1 localhost - - [25/Aug/2008 23:08:29] "POST /RPC2 HTTP/1.0" 200 - 2 localhost - - [25/Aug/2008 23:08:30] "POST /RPC2 HTTP/1.0" 200 - 3 localhost - - [25/Aug/2008 23:08:31] "POST /RPC2 HTTP/1.0" 200 - 1 As expected. I guess that your problem was on this line: server.register_function( servg.next, 'gen' ) where instead you just wrote server.register_function( servg, 'gen' ) #wrong or perhaps even server.register_function( gen, 'gen' ) #wrong I'll offer an explanation of the difference too, for the asking. -- http://mail.python.org/mailman/listinfo/python-list