[Twisted-Python] win32 process problem

Drew Whitehouse Drew.Whitehouse at anu.edu.au
Tue Mar 19 23:14:09 EST 2002


Hi Itamar,

I'm just getting into twisted, after our IRC chat the other day. Looks
like it does everything I need (plus a lot more !). I'm having some
trouble with Process and win32, i.e. I'm already using bleeding edge
CVS versions ... I'm trying to run a http server which services XMLRPC
calls. The XMLRPC calls then have to launch a process that the server
needs to keep track of, getting notified when the process exits.
Anyhow it seems the new win32 process stuff is giving trouble. It only
allows one XMLRPC call before the server hangs. I'm testing with the
following code.

I realize that this code is brand new, but thought I'd send it along
in case you hadn't seen the problem already.

-Drew

-----------server.py------------------

import sys,os
if sys.platform == 'win32':
    from twisted.internet import win32
    print 'Installing WIN32 version of process handling etc ...'
    win32.install()

from twisted.web import xmlrpc
from twisted.python import defer
import xmlrpclib

class Echoer(xmlrpc.XMLRPC):
    def _getFunction(self, functionPath):
        """Convert the functionPath to a method beginning with
'xmlrpc_'.

        For example, 'echo' returns the method 'xmlrpc_echo'.
        """
        f = getattr(self, "xmlrpc_%s" % functionPath, None)
        if f:
            return f
        else:
            raise xmlrpc.NoSuchFunction
    def xmlrpc_hello(self):
        """Return 'hello, world'."""
        return 'hello, world!'

def main():
    from twisted.internet.app import Application
    from twisted.web import server
    app = Application("xmlrpc")
    r = Echoer()
    app.listenTCP(7080, server.Site(r))
    app.run(0)

if __name__ == '__main__':
    main()

and

-------client.py------------------------
import xmlrpclib
proxy = xmlrpclib.Server("http://localhost:7080/")
r = proxy.hello()
print r



-Drew

;; Drew.Whitehouse at anu.edu.au      Sci-Viz/VR Programmer
;; http://anusf.anu.edu.au/~drw900          ANUSF VIZLAB
;; Australian National University Supercomputer Facility





More information about the Twisted-Python mailing list