intervall of about 1 second for xmlrpc calls?

Discussion in 'Python' started by Thomas Lehmann, May 20, 2010.

  1. Hi,

    I'm wondering about the behavior. Running this example - it looks like
    - that each rpc call is triggered in a visible interval (about one
    second).

    What's wrong?

    Thomas

    APPENDIX:

    <code>
    import threading
    from xmlrpc.server import SimpleXMLRPCServer
    import xmlrpc.client

    class MyServer(threading.Thread):
    def __init__(self, host, port):
    threading.Thread.__init__(self)
    self.server = SimpleXMLRPCServer((host, port))
    self.server.register_function(self.is_even, "is_even")
    self.server.register_function(self.stop, "stop_server")

    def run(self):
    print("server: waiting for requests...")
    self.server.serve_forever()
    print("server: is down.")

    def stop(self):
    print("server: shutdown requested...")
    self.stoptimer = threading.Timer(1, self.server.shutdown)
    self.stoptimer.start()
    return "done."

    def is_even(self, n):
    print("server: check %d to be even" % (n))
    return n%2 == 0


    # server as thread
    server = MyServer("localhost", 1234)
    server.start()

    # client code
    serverProxy = xmlrpc.client.ServerProxy("http://localhost:1234")
    for n in range(1,2+1):
    print("%d is %s" % (n, ["odd", "even"][serverProxy.is_even(n)]))
    serverProxy.stop_server()
    </code>
    Thomas Lehmann, May 20, 2010
    #1
    1. Advertising

  2. > What's wrong?
    >


    Obviously there's a problem with "localhost". When using the IP of my
    machine everything is working fast.
    Thomas Lehmann, May 20, 2010
    #2
    1. Advertising

  3. On Thu, 2010-05-20 at 03:40 -0700, Thomas Lehmann wrote:
    > > What's wrong?

    > Obviously there's a problem with "localhost". When using the IP of my
    > machine everything is working fast.


    You box may first be trying to connect to ::1 (ipv6) and when that fails
    it falls back to 127.0.0.1. Make sure IPv6 is properly
    configured/enabled and try the script again.
    --
    Adam Tauno Williams <> LPIC-1, Novell CLA
    <http://www.whitemiceconsulting.com>
    OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba
    Adam Tauno Williams, May 20, 2010
    #3
  4. Thomas Lehmann

    News123 Guest

    Hi Adam,


    Adam Tauno Williams wrote:
    > On Thu, 2010-05-20 at 03:40 -0700, Thomas Lehmann wrote:
    >>> What's wrong?

    >> Obviously there's a problem with "localhost". When using the IP of my
    >> machine everything is working fast.


    I think you're right.

    localhost with IPV6 was also a problem for me. At least it was for me
    on a windows 7 host.
    I 'solved' the problem by disabling IPV6, but this is a workaround, not
    a proper solution.

    >
    > You box may first be trying to connect to ::1 (ipv6) and when that fails
    > it falls back to 127.0.0.1. Make sure IPv6 is properly
    > configured/enabled and try the script again.


    Do you know why the default config of IPV6 could be wrong on a windows
    7 host?

    Having no experience with IPV6:

    How should it be configured?
    How to detect issues?


    thanks


    N
    News123, May 20, 2010
    #4
  5. On Thu, 2010-05-20 at 22:46 +0200, News123 wrote:
    > Hi Adam,
    > Adam Tauno Williams wrote:
    > > On Thu, 2010-05-20 at 03:40 -0700, Thomas Lehmann wrote:
    > >>> What's wrong?
    > >> Obviously there's a problem with "localhost". When using the IP of my
    > >> machine everything is working fast.

    > I think you're right.
    > localhost with IPV6 was also a problem for me. At least it was for me
    > on a windows 7 host.
    > I 'solved' the problem by disabling IPV6, but this is a workaround, not
    > a proper solution.
    > > You box may first be trying to connect to ::1 (ipv6) and when that fails
    > > it falls back to 127.0.0.1. Make sure IPv6 is properly
    > > configured/enabled and try the script again.

    > Do you know why the default config of IPV6 could be wrong on a windows
    > 7 host?


    No. This would seem to have something to do with the resolver. If you
    do a nslookup for localhost what does it say.

    > Having no experience with IPV6:


    Have lots, it's really nice. Once you get most things cut over.

    > How should it be configured?
    > How to detect issues?


    Does nslookup localhost return the correct result? That might depend on
    your DNS server - not your local host.

    Also "ping ::1"?
    --
    Adam Tauno Williams <> LPIC-1, Novell CLA
    <http://www.whitemiceconsulting.com>
    OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba
    Adam Tauno Williams, May 20, 2010
    #5
  6. Thomas Lehmann

    rav Guest

    I had similar problem with SimpleXMLRPCServer
    Create the request handler class

    class ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
    # originally this one was slowing down my server A LOT due to DNS
    settings!!!
    def log_request(self, *args):
    pass

    and put it in your SimpleXMLRPCServer constructor

    (...)

    class MyServer(threading.Thread):
    def __init__(self, host, port):
    threading.Thread.__init__(self)
    self.server = SimpleXMLRPCServer((host, port),
    ExtendedXMLRPCRequestHandler)
    self.server.register_function(self.is_even, "is_even")
    self.server.register_function(self.stop, "stop_server")

    (...)

    I would also change all 'localhost' occurences in the code to ip
    '127.0.0.1'.

    Good luck!
    Rafal
    rav, May 21, 2010
    #6
  7. On Fri, 2010-05-21 at 02:10 -0700, rav wrote:
    > I had similar problem with SimpleXMLRPCServer
    > Create the request handler class
    > class ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
    > # originally this one was slowing down my server A LOT due to DNS
    > settings!!!
    > def log_request(self, *args):
    > pass
    > and put it in your SimpleXMLRPCServer constructor
    > (...)
    > class MyServer(threading.Thread):
    > def __init__(self, host, port):
    > threading.Thread.__init__(self)
    > self.server = SimpleXMLRPCServer((host, port),
    > ExtendedXMLRPCRequestHandler)
    > self.server.register_function(self.is_even, "is_even")
    > self.server.register_function(self.stop, "stop_server")
    > (...)
    > I would also change all 'localhost' occurences in the code to ip
    > '127.0.0.1'.


    Or the better solution is to fix your resolver.
    --
    Adam Tauno Williams <> LPIC-1, Novell CLA
    <http://www.whitemiceconsulting.com>
    OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba
    Adam Tauno Williams, May 21, 2010
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve

    Date intervall parsing

    Steve, Jul 18, 2005, in forum: Java
    Replies:
    4
    Views:
    354
    Steve
    Jul 18, 2005
  2. Etienne Posthumus
    Replies:
    1
    Views:
    1,094
    Roger Binns
    Apr 1, 2004
  3. Xavier

    proxy for xmlrpc calls

    Xavier, Aug 13, 2006, in forum: Python
    Replies:
    1
    Views:
    311
    Fredrik Lundh
    Aug 14, 2006
  4. Rickard Sjostrom

    Hanging XMLRPC calls

    Rickard Sjostrom, Sep 24, 2009, in forum: Ruby
    Replies:
    1
    Views:
    137
    Rickard Sjostrom
    Sep 29, 2009
  5. yelipolok
    Replies:
    4
    Views:
    239
    John W. Krahn
    Jan 27, 2010
Loading...

Share This Page