python2.2: signals and exceptions: interrupted system call

J

Jakub Moscicki

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('hello')
File
"/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPackages/2.0.0/lib/python2.2/xmlrpclib.py",
line 821, in __call__
return self.__send(self.__name, args)
File
"/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPackages/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/PublicDomainPackages/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/PublicDomainPackages/2.0.0/lib/python2.2/httplib.py",
line 752, in getreply
response = self._conn.getresponse()
File
"/tmp/DIANE/install/anaphe_top/specific/redhat73/gcc-3.2/PublicDomainPackages/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/PublicDomainPackages/2.0.0/lib/python2.2/httplib.py",
line 119, in begin
line = self.fp.readline()
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.ServerProxy(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(signal.SIGALRM, handler)
signal.alarm(timeout)

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


--
server.py
--

import SimpleXMLRPCServer

SERVER = 'localhost'
log = 1

server = SimpleXMLRPCServer.SimpleXMLRPCServer((SERVER, 8001), logRequests=log)

try:
server.register_function(lambda x: x, 'echo')
server.serve_forever()
finally:
server.socket.close()
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Jakub said:
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.

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
 
J

Jakub Moscicki

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.

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.

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

kuba
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top