473,387 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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('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()

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

Jul 18 '05 #1
2 4554
Jakub Moscicki wrote:
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

Jul 18 '05 #2
> > 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

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

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Siemel Naran | last post by:
Hi. I posted this question to comp.lang.c++, but am rephrasing it a bit from what I learned and posting to comp.lang.c++.moderated for more insight. So how do I solve my problem? I want it so...
4
by: Mantorok Redgormor | last post by:
Should I just avoid them? I have heard many bad things about them 1) if you set a signal handler, you can't really ignore the signal and continue with normal program execution, because after that...
11
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
4
by: Joe Van Dyk | last post by:
The C++ language doesn't deal with signals (i.e. SIGINT, SIGKILL), right? Joe
6
by: geoffbache | last post by:
Hi all, I have a Python program (on UNIX) whose main job is to listen on a socket, for which I use the SocketServer module. However, I would also like it to be sensitive to signals received,...
11
by: vippstar | last post by:
What is the purpose of signals and why do they exist in C? thanks in advance
3
by: alan | last post by:
This ignores CTRL-C on every platform I've tested: python -c "import threading; threading.Event().wait()" ^C^C^C^C It looks to me like all signals are masked before entering wait(). Can...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: Tim Golden | last post by:
Lowell Alleman wrote: Well you've certainly picked a ticklish area to run into problems with ;). First, forget about the threading aspects for the moment. AFAICT the smallest program which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.