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
------------------------------------------------------------- 2 4584
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
> > 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
------------------------------------------------------------- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 that when the user presses
Ctrl-C or eds the task from task manager (or the kill command in UNIX) then
the system should shutdown gracefully. This means it should call the
destructors of all objects, which means freeing dynamic memory, closing...
|
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 undefined
behavior is invoked.
2) if you have a signal handler set for say SIG_INT and you continue
to reset the handler after you received the signal, to continue normal
program execution, and the signal is received twice or something you
end...
|
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.
|
by: Joe Van Dyk |
last post by:
The C++ language doesn't deal with signals (i.e. SIGINT, SIGKILL), right?
Joe
|
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, which it isn't if it's
listening on the socket. ("signals can only be received between atomic
actions of the python interpreter", presumably - and control will not
return to Python unless something appears on the socket). Does anyone
have a tip of a...
| |
by: vippstar |
last post by:
What is the purpose of signals and why do they exist in C?
thanks in advance
|
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
someone familiar with the internals explain and/or justify this
behavior? Thanks,
-Alan
|
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 I
don't see the error):
"System.IO.IOException: Unable to read data from the transport connection:A
blocking operation was interrupted by a call to WSACancelBlockingCall"
|
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 reproduces your problem is:
<code>
import signal
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |