python2.2: signals and exceptions: interrupted system call

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jakub Moscicki

    python2.2: signals and exceptions: interrupted system call

    Hello,

    A small problem: I get a signal during a system call (from xmlrpclib ->
    httplib) and an exception "IOError: [Errno 4] Interrupted system call" is
    raised (this is system dependant, on other machine it does not raise this
    exception). I have my own signal handler so I want to simply ignore this
    exception if it occures. But for a reason mysterious to me I cannot catch
    this exception in the main's program try block.

    Anybody knows what's wrong? Code listings below.

    Thanks,

    kuba

    -------------------
    python2.2 client.py
    <ServerProxy for xyz.com:8001/RPC2>
    Signal handler called with signal 14
    I made 51 calls in 3 seconds
    Traceback (most recent call last):
    File "client.py" , line 31, in ?
    server.echo('he llo')
    File
    "/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPac kages/2.0.0/lib/python2.2/xmlrpclib.py",
    line 821, in __call__
    return self.__send(sel f.__name, args)
    File
    "/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPac kages/2.0.0/lib/python2.2/xmlrpclib.py",
    line 975, in __request
    verbose=self.__ verbose
    File
    "/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPac kages/2.0.0/lib/python2.2/xmlrpclib.py",
    line 842, in request
    errcode, errmsg, headers = h.getreply()
    File
    "/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPac kages/2.0.0/lib/python2.2/httplib.py",
    line 752, in getreply
    response = self._conn.getr esponse()
    File
    "/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPac kages/2.0.0/lib/python2.2/httplib.py",
    line 595, in getresponse
    response.begin( )
    File
    "/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPac kages/2.0.0/lib/python2.2/httplib.py",
    line 119, in begin
    line = self.fp.readlin e()
    IOError: [Errno 4] Interrupted system call

    -------------------
    If you want to reproduce the problem try this with python2.2:

    --
    client.py
    --

    import xmlrpclib

    SERVER = "http://localhost:8001"
    server = xmlrpclib.Serve rProxy(SERVER) # local server

    timeout = 3

    print server

    import signal, os

    global terminate

    def handler(signum, frame):
    global terminate
    print 'Signal handler called with signal', signum
    terminate = 1

    signal.signal(s ignal.SIGALRM, handler)
    signal.alarm(ti meout)

    cnt = 0
    terminate = 0
    try:
    try:
    while not terminate:
    server.echo('he llo')
    cnt += 1
    except xmlrpclib.Error , v:
    print "ERROR", v
    finally:
    print "I made %d calls in %d seconds" % (cnt,timeout)


    --
    server.py
    --

    import SimpleXMLRPCSer ver

    SERVER = 'localhost'
    log = 1

    server = SimpleXMLRPCSer ver.SimpleXMLRP CServer((SERVER , 8001), logRequests=log )

    try:
    server.register _function(lambd a x: x, 'echo')
    server.serve_fo rever()
    finally:
    server.socket.c lose()

    --
    -------------------------------------------------------------
    mow mi KUBA call me KUBA appelle-moi KUBA
    -------------------------------------------------------------

  • Martin v. Löwis

    #2
    Re: python2.2: signals and exceptions: interrupted system call

    Jakub Moscicki wrote:
    [color=blue]
    > A small problem: I get a signal during a system call (from xmlrpclib ->
    > httplib) and an exception "IOError: [Errno 4] Interrupted system call" is
    > raised (this is system dependant, on other machine it does not raise this
    > exception). I have my own signal handler so I want to simply ignore this
    > exception if it occures. But for a reason mysterious to me I cannot catch
    > this exception in the main's program try block.[/color]

    I cannot find anything mysterious here: The exception is IOError, but
    you try to catch xmlrpclib.error , so you are not catching IOError, so
    raising IOError aborts your program.

    Regards,
    Martin

    Comment

    • Jakub Moscicki

      #3
      Re: python2.2: signals and exceptions: interrupted system call

      > > A small problem: I get a signal during a system call (from xmlrpclib ->[color=blue][color=green]
      > > httplib) and an exception "IOError: [Errno 4] Interrupted system call" is
      > > raised (this is system dependant, on other machine it does not raise this
      > > exception). I have my own signal handler so I want to simply ignore this
      > > exception if it occures. But for a reason mysterious to me I cannot catch
      > > this exception in the main's program try block.[/color]
      >
      > I cannot find anything mysterious here: The exception is IOError, but
      > you try to catch xmlrpclib.error , so you are not catching IOError, so
      > raising IOError aborts your program.[/color]

      Yes, you are right. Mea culpa. Too many hours against too many
      lines of code ;)

      kuba

      --
      -------------------------------------------------------------
      mow mi KUBA call me KUBA appelle-moi KUBA
      -------------------------------------------------------------

      Comment

      Working...