473,289 Members | 2,106 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,289 software developers and data experts.

Signal handler doesn`t handle any signals while main thread is blocked

Hi!
I waste a lot of my time figuring why this snip of code doesn`t work.
And still without any solution ;/
Does anybody know why this handler cannot handle SIGINT signal? What
did I wrong?

Thanks in advance.

#
# CODE
#
import signal
from threading import *

def siginthandler(signum, frame):
global work,cv
print 'terminating...'
cv.acquire()
work = 0
cv.notifyAll ()
cv.release()

work = 1
signal.signal (signal.SIGINT, siginthandler)

print 'wait for SIGINT signal'
cv = Condition ()
cv.acquire()
while work:
print 'waiting...'
cv.wait()
print 'woke up'
cv.release()

print 'terminated'
Jun 27 '08 #1
1 2077
On May 26, 2:26*pm, "Grzegorz Kokosiński" <g.kokosin...@gmail.com>
wrote:
Hi!
I waste a lot of my time figuring why this snip of code doesn`t work.
And still without any solution ;/
Does anybody know why this handler cannot handle SIGINT signal? What
did I wrong?

Thanks in advance.

#
# CODE
#
import signal
from threading import *

def siginthandler(signum, frame):
* * *global work,cv
* * *print 'terminating...'
* * *cv.acquire()
* * *work = 0
* * *cv.notifyAll ()
* * *cv.release()

work = 1
signal.signal (signal.SIGINT, siginthandler)

print 'wait for SIGINT signal'
cv = Condition ()
cv.acquire()
while work:
* * print 'waiting...'
* * cv.wait()
print 'woke up'
cv.release()

print 'terminated'
change cv.wait() to cv.wait(delay) and it will capture the terminate
request and wrap the cv.wait(delay) in a try/except IOError: break
block.
Jun 27 '08 #2

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

Similar topics

8
by: Elf M. Sternberg | last post by:
I'm having a devil of a time with signal handling under BSD 4.4 with Python and I was hoping that this might ring a bell with someone. Using the Webware Application Server (a multi-threaded Python...
2
by: Holger Joukl | last post by:
Hi, migrating from good old python 1.5.2 to python 2.3, I have a problem running a program that features some threads which execute calls to an extension module. Problem is that all of a sudden,...
2
by: lpw | last post by:
I have dilligently reviewed FAQ-lite Section 3.2, "How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc." The only...
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.
2
by: gnutuxy | last post by:
Hi, I am newbie in the Unix system programming and in learning phase. I usually read the libc manual and then try to implement small programs to test/check the learnt thing. I read the libc...
7
by: Adrian Casey | last post by:
I have a multi-threaded python application which uses pexpect to connect to multiple systems concurrently. Each thread within my application is a connection to a remote system. The problem is...
10
by: Udai Kiran | last post by:
Hi all Iam having trouble with signal handler. Where will the execution return after invoking a signal handler when that particular signal is recieved? will return to the point where we register...
5
by: david | last post by:
I'm developing a program that runs using an asyncore loop. Right now I can adequately terminate it using Control-C, but as things get refined I need a better way to stop it. I've developed...
5
by: Yves Dorfsman | last post by:
I did a few tests with this script: class byebye: def __del__(self): print 'Bye, bye...' x = byebye()
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.