Python signal processing question

All, I have searched everywhere (mostly the code and a little google) and I cannot understand where the SIGKILL signal gets checked when it is set as a handler. I have scoured the Modules/signalmodule.c only to find two instances of the RuntimeError exception, but I cannot understand how python knows when a handler is set for SIGKILL. I understand that this changed in 2.4 and I am not trying to change it, I just really want to understand where this happens. I used grep to find SIGKILL and SIGTERM to see if I could determine where the critical difference is, but I cannot figure it out. I have about 2 hours of searching around and I can't figure it out, I assume it has to rely on some default behaviour in Unix, but I have no idea. I don't see a difference between SIGKILL and SIGTERM in the python code, but obviously there is some difference. I understand what the difference is in Unix/Linux, I just want to see it in the python code. Since python is checking at run time to see what signals handlers are added, I know there must be a difference. Please can someone just point me in the right direction. Thank You Scott M

Hello. We'are sorry but we cannot help you. This mailing list is to work on developing Python (fixing bugs and adding new features to Python itself); if you're having problems using Python, please find another forum. Probably python-list (comp.lang.python) news group/mailing list is the best place. See http://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding. Regarding SIGKILL - read "man kill" carefully. Or better yet, a Unix programmer guide. On Mon, Jul 19, 2010 at 12:11:10PM -0400, Scott McCarty wrote:
All, I have searched everywhere (mostly the code and a little google) and I cannot understand where the SIGKILL signal gets checked when it is set as a handler. I have scoured the Modules/signalmodule.c only to find two instances of the RuntimeError exception, but I cannot understand how python knows when a handler is set for SIGKILL. I understand that this changed in 2.4 and I am not trying to change it, I just really want to understand where this happens. I used grep to find SIGKILL and SIGTERM to see if I could determine where the critical difference is, but I cannot figure it out.
I have about 2 hours of searching around and I can't figure it out, I assume it has to rely on some default behaviour in Unix, but I have no idea. I don't see a difference between SIGKILL and SIGTERM in the python code, but obviously there is some difference. I understand what the difference is in Unix/Linux, I just want to see it in the python code. Since python is checking at run time to see what signals handlers are added, I know there must be a difference.
Please can someone just point me in the right direction.
Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

I apologize if this is the wrong place to ask questions about Python C code, but I didn't know where else to turn. I don't think the regular user group will be technical enough to find this, am I wrong? There is no forum for something this in depth. This is not a usage problem, I want to know where in the code this is happening, I understand how to use these signals perfectly and why they are different. Clearly SIGKILL cannot be caught and would never get used even if you did register that handler in Python, while SIGTERM is able to be caught, this is standard Unix signals. The part I am asking about is how python checks ahead of time. If it didn't check (case before python 2.4), then it would get silently ignored because the OS would kill the process without ever letting python even try and handle that signal. I just want to understand the C/Python piece better because I am writing a tutorial on signals and I am using python to demonstrate. I thought it would be fun to show that the SIGKILL is never processed, but instead python errors out. There is something in Python checking the SIGKILL signal handler, while not checking SIGTERM and I can't find the Python C code that handles it. When I am writing something like this, I like to point out the C code, not just cite the documentation (I did find this change in behaviour noted in the Python change log). I will try and find a different list Scott M On Mon, Jul 19, 2010 at 12:27 PM, Oleg Broytman <phd@phd.pp.ru> wrote:
Hello.
We'are sorry but we cannot help you. This mailing list is to work on developing Python (fixing bugs and adding new features to Python itself); if you're having problems using Python, please find another forum. Probably python-list (comp.lang.python) news group/mailing list is the best place. See http://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding.
Regarding SIGKILL - read "man kill" carefully. Or better yet, a Unix programmer guide.
All, I have searched everywhere (mostly the code and a little google) and I cannot understand where the SIGKILL signal gets checked when it is set as a handler. I have scoured the Modules/signalmodule.c only to find two instances of the RuntimeError exception, but I cannot understand how
On Mon, Jul 19, 2010 at 12:11:10PM -0400, Scott McCarty wrote: python
knows when a handler is set for SIGKILL. I understand that this changed in 2.4 and I am not trying to change it, I just really want to understand where this happens. I used grep to find SIGKILL and SIGTERM to see if I could determine where the critical difference is, but I cannot figure it out.
I have about 2 hours of searching around and I can't figure it out, I assume it has to rely on some default behaviour in Unix, but I have no idea. I don't see a difference between SIGKILL and SIGTERM in the python code, but obviously there is some difference. I understand what the difference is in Unix/Linux, I just want to see it in the python code. Since python is checking at run time to see what signals handlers are added, I know there must be a difference.
Please can someone just point me in the right direction.
Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

On Mon, Jul 19, 2010 at 01:09:36PM -0400, Scott McCarty wrote:
I apologize if this is the wrong place to ask questions about Python C code, but I didn't know where else to turn. I don't think the regular user group will be technical enough to find this, am I wrong?
I am sure there are quite a lot of skilled professionals in the python-list (comp.lang.python).
On Mon, Jul 19, 2010 at 12:27 PM, Oleg Broytman <phd@phd.pp.ru> wrote:
python-list (comp.lang.python) news group/mailing list is the best place. See http://www.python.org/community/ for other lists/news groups/fora.
Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

We'are sorry but we cannot help you. This mailing list is to work on developing Python (fixing bugs and adding new features to Python itself); if you're having problems using Python, please find another forum. Probably python-list (comp.lang.python) news group/mailing list is the best place. See http://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding.
Regarding SIGKILL - read "man kill" carefully. Or better yet, a Unix programmer guide.
Wha? How could this not be the right place? He's not asking about USING python, but asking: WHERE in the PYTHON CODE BASE does the signal get checked? A-bit-miffed-at-the-cold-shoulderly yours, Marcos (wink wink)

On 7/19/2010 11:08 PM, average wrote:
We'are sorry but we cannot help you. This mailing list is to work on developing Python (fixing bugs and adding new features to Python itself); if you're having problems using Python, please find another forum. Probably python-list (comp.lang.python) news group/mailing list is the best place. See http://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding.
Regarding SIGKILL - read "man kill" carefully. Or better yet, a Unix programmer guide.
Wha? How could this not be the right place? He's not asking about USING python, but asking: WHERE in the PYTHON CODE BASE does the signal get checked?
A-bit-miffed-at-the-cold-shoulderly yours,
Marcos (wink wink)
+1 Another potential developer walks away feeling unwanted? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 DjangoCon US September 7-9, 2010 http://djangocon.us/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/

On 7/19/2010 6:08 PM, average wrote:
We'are sorry but we cannot help you. This mailing list is to work on developing Python (fixing bugs and adding new features to Python itself); if you're having problems using Python, please find another forum. Probably python-list (comp.lang.python) news group/mailing list is the best place. See http://www.python.org/community/ for other lists/news groups/fora. Thank you for understanding.
This is a polite boilerplate response for off-topic posts. I suppose 'using' should be expanded to 'using or understanding'.
Regarding SIGKILL - read "man kill" carefully. Or better yet, a Unix programmer guide.
Wha? How could this not be the right place? He's not asking about USING python, but asking: WHERE in the PYTHON CODE BASE does the signal get checked?
Right, he asked about how Python operates, which is a constant type of question on python-list and which has nothing to do with developing the next version(s) of Python.
A-bit-miffed-at-the-cold-shoulderly yours,
Py-dev was started when python-list because unusable for development. If this list were to become, in turn, overwhelmed with general questions, as it would be it non-development questions were not directed elsewhere, then the devs would have to start a new python-really-development-only list, and perhaps not make it so public. If someone tries an advanced question on python-list first and gets no answer, then there might be an excuse to turn to py-dev to grab the attention of those developers who do not ever read python-list. But in this case, the question was readily answered there, in part by devs who do frequent both. The OP acknowledged there that he acted on prejudice and should have posted there in the first place. -- Terry Jan Reedy

On Mon, Jul 19, 2010 at 04:08:00PM -0600, average wrote:
Wha? How could this not be the right place? He's not asking about USING python, but asking: WHERE in the PYTHON CODE BASE does the signal get checked?
A-bit-miffed-at-the-cold-shoulderly yours,
Marcos (wink wink)
I know, the task of sending answers like I've sent is quite unappreciated. I know, the meaning of my answer is rude because, in short, it's simply "Please, go away", and however I stress the "please" part it's still "go away". If I were a help seeker it'd be quite a hard blow for me to receive such an answer. Yes, I know. Still, two other alternatives are even worse. The first alternative is to not answer "using" questions at all; quite rude. The second is answer all questions and make the developers quit the list and found a new quiet one. I don't see any other alternative, do you? Of those three - which one do you prefer? The original question was about using python, that's my understanding. Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

On 7/20/2010 11:59 AM, Oleg Broytman wrote:
On Mon, Jul 19, 2010 at 04:08:00PM -0600, average wrote:
Wha? How could this not be the right place? He's not asking about USING python, but asking: WHERE in the PYTHON CODE BASE does the signal get checked?
A-bit-miffed-at-the-cold-shoulderly yours,
Marcos (wink wink)
I know, the task of sending answers like I've sent is quite unappreciated. I know, the meaning of my answer is rude because, in short, it's simply "Please, go away", and however I stress the "please" part it's still "go away". If I were a help seeker it'd be quite a hard blow for me to receive such an answer. Yes, I know.
No, the reply is fine as far as it goes, and I am sure the poster did get a reply from c.l.py, but his question revealed a thirst for knowledge not usually evidenced in non-dev inquiries.
Still, two other alternatives are even worse. The first alternative is to not answer "using" questions at all; quite rude. The second is answer all questions and make the developers quit the list and found a new quiet one. I don't see any other alternative, do you? Of those three - which one do you prefer? The original question was about using python, that's my understanding.
Could we perhaps include a link to the material for Python devs, just so people realise that although they are being sent away for good reason, if they are interested in joining the dev community there is material to help and guide them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 DjangoCon US September 7-9, 2010 http://djangocon.us/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/

No, the reply is fine as far as it goes, and I am sure the poster did get a reply from c.l.py, but his question revealed a thirst for knowledge not usually evidenced in non-dev inquiries.
Unfortunately (?) the question also revealed a lack of understanding of a fairly basic concept. IIUC, he wanted to know how Python handles SIGKILL, when the hole point of SIGKILL is that you cannot handle it. So he shouldn't have been surprised that he couldn't find a place in Python where it's handled. Regards, Martin

On Wed, Jul 21, 2010 at 4:43 AM, "Martin v. Löwis" <martin@v.loewis.de> wrote:
Unfortunately (?) the question also revealed a lack of understanding of a fairly basic concept. IIUC, he wanted to know how Python handles SIGKILL, when the hole point of SIGKILL is that you cannot handle it. So he shouldn't have been surprised that he couldn't find a place in Python where it's handled.
No, you misunderstood. He knew that one cannot set a SIGKILL signal handler. He just wanted to find the code in CPython responsible for turning that error into an exception for the purposes of giving a tutorial on signals. Reid

On 21/07/10 23:43, "Martin v. Löwis" wrote:
IIUC, he wanted to know how Python handles SIGKILL, when the hole point of SIGKILL is that you cannot handle it.
No, I think he wanted to know how Python disallows attempting to set a handler for SIGKILL, when he couldn't find any code that special-cases SIGKILL in the implementation of signal(). Although he didn't express the question all that clearly, so it's hard to tell. -- Greg

On Tue, Jul 20, 2010 at 6:59 AM, Oleg Broytman <phd@phd.pp.ru> wrote: ..
I know, the task of sending answers like I've sent is quite unappreciated. I know, the meaning of my answer is rude because, in short, it's simply "Please, go away", and however I stress the "please" part it's still "go away". If I were a help seeker it'd be quite a hard blow for me to receive such an answer. Yes, I know. Still, two other alternatives are even worse. The first alternative is to not answer "using" questions at all; quite rude. The second is answer all questions and make the developers quit the list and found a new quiet one. I don't see any other alternative, do you? Of those three - which one do you prefer?
People dislike canned responses no matter how friendly and polite they sound. I believe python-dev tradition is to redirect the poster to python-list but still include at least a hint to what the answer to his or her question is. I believe this works fairly well.

On 7/20/2010 6:59 AM, Oleg Broytman wrote:
I know, the task of sending answers like I've sent is quite unappreciated.
*I* appreciate it. I mostly do not respond to such because I expect you or Aahz will.
I know, the meaning of my answer is rude because, in short, it's simply "Please, go away", and however I stress the "please" part it's still "go away". If I were a help seeker it'd be quite a hard blow for me to receive such an answer. Yes, I know.
1. I suggested one improvement to the canned response in my previous post: expand 'using' to 'using or understanding'. 2. Here is another: mention that Python developers who are willing to answer non-development questions already participate on python-list/gmane.comp.python.general to answer such questions there. 3. That brings up: also mention gmane.comp.python.general, for those like me who prefer the newsgroup interface. 4. Alexander Belopolsky wrote: "People dislike canned responses no matter how friendly and polite they sound. I believe python-dev tradition is to redirect the poster to python-list but still include at least a hint to what the answer to his or her question is." I believe you *did* do that, but it was easily missed. So: end the boilerplate with ------------------------------------------------------------- and put hints here so they stand out.
Still, two other alternatives are even worse. The first alternative is to not answer "using" questions at all; quite rude. The second is answer all questions and make the developers quit the list and found a new quiet one.
I brought up that same possibility.
I don't see any other alternative, do you? Of those three - which one do you prefer? The original question was about using python, that's my understanding.
I agree that it appeared to be, but it was phrased in terms of understanding its operation, hence the claim that it was not, and hence suggestion 1) above. -- Terry Jan Reedy

On Tue, Jul 20, 2010 at 01:51:07PM -0400, Terry Reedy wrote:
On 7/20/2010 6:59 AM, Oleg Broytman wrote: 1. I suggested one improvement to the canned response in my previous post: expand 'using' to 'using or understanding'.
I changed wording to "if you're having problems learning, understanding or using Python"
2. Here is another: mention that Python developers who are willing to answer non-development questions already participate on python-list/gmane.comp.python.general to answer such questions there.
Good addition, thank you! I'll add something like "there are Python developers who participate on python-list/comp.lang.python".
3. That brings up: also mention gmane.comp.python.general, for those like me who prefer the newsgroup interface.
It is referenced at http://www.python.org/community/lists/ and my text points to http://www.python.org/community/; I think it's enough. Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

1. I suggested one improvement to the canned response in my previous post: expand 'using' to 'using or understanding'.
I changed wording to "if you're having problems learning, understanding or using Python"
I think it's critical to disambiguate between questions about "using and programming with the Python language" versus working with the actual code base that makes Python. Your boilerplate is appropriate for the former, but completely confusing for the latter. As to your question of how best to handle inquiries from the blue or "noisy questions", I personally prefer the following (only slightly tongue-in-cheek): ...After a sufficient period of waiting, say a day or two with no response: "busy busy busy, the gnomes must be hard at work. You've no answer. That means that your question(s) either isn't interesting enough in an obvious way, or it's simply off-topic. If you feel you been unfairly ignored, you might try rewording the question, doing some research to show that you've checked the obvious, or try the following venues: comp.lang.python, for blah blah blah python-ideas,for pitching your new lambda form, to etc, etc" In any case, Mr Crute gave a quite perfect answer, not that such detail should be exptected. Cheers, Marcos

On Wed, Jul 21, 2010 at 07:28:24PM -0600, average wrote:
As to your question of how best to handle inquiries from the blue or "noisy questions", I personally prefer the following (only slightly tongue-in-cheek):
...After a sufficient period of waiting, say a day or two with no response:
Ok, I'll wait a bit longer. Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

Oleg Broytman writes:
On Wed, Jul 21, 2010 at 07:28:24PM -0600, average wrote:
As to your question of how best to handle inquiries from the blue or "noisy questions", I personally prefer the following (only slightly tongue-in-cheek):
...After a sufficient period of waiting, say a day or two with no response:
Ok, I'll wait a bit longer.
I don't think that's a good idea. It just encourages people to give a response on python-dev plus follow-ups, and if they give an answer without saying "you'd better ask this on comp.lang.python", when you do, you look like a netcop rather than being helpful. The mail you originally sent was sufficiently polite and clear IMO, but anything can be improved and I'm glad you took up the suggestions on the wording. OTOH I think as quick as possible an answer is a good idea here. It saves the intended audience the thought about whether to reply or not, and an instant, constructive answer says that somebody cares. The message should be "The people who will answer your question on python-dev are also on comp.lang.python, as well as many more (you may get a faster, and probably more complete, answer on comp.lang.python). The people on python-dev don't need to see the answer (they already know it), but the people on comp.lang.python are likely to be happy to learn it."

On Thu, Jul 22, 2010 at 06:02:33PM +0900, Stephen J. Turnbull wrote:
Oleg Broytman writes:
On Wed, Jul 21, 2010 at 07:28:24PM -0600, average wrote:
As to your question of how best to handle inquiries from the blue or "noisy questions", I personally prefer the following (only slightly tongue-in-cheek):
...After a sufficient period of waiting, say a day or two with no response:
Ok, I'll wait a bit longer.
I don't think that's a good idea. It just encourages people to give a response on python-dev plus follow-ups, and if they give an answer without saying "you'd better ask this on comp.lang.python", when you do, you look like a netcop rather than being helpful.
Yes, that's a kind of a problem. Not a big one - I live in the "wrong" time zone and can afford to wait a few hours. Certainly not a few days.
The mail you originally sent was sufficiently polite and clear IMO, but anything can be improved and I'm glad you took up the suggestions on the wording.
OTOH I think as quick as possible an answer is a good idea here. It saves the intended audience the thought about whether to reply or not, and an instant, constructive answer says that somebody cares. The message should be "The people who will answer your question on python-dev are also on comp.lang.python, as well as many more (you may get a faster, and probably more complete, answer on comp.lang.python). The people on python-dev don't need to see the answer (they already know it), but the people on comp.lang.python are likely to be happy to learn it."
Thank you. I'll think how to add something like this so that my boilerplate wouldn't become too big, Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

On Thu, 22 Jul 2010 07:02:33 pm Stephen J. Turnbull wrote:
OTOH I think as quick as possible an answer is a good idea here. It saves the intended audience the thought about whether to reply or not, and an instant, constructive answer says that somebody cares.
+1 I think that waiting "a day or two" as suggested by Average does nobody any good. It doesn't help the poster, who will almost certainly have given up by then, and may have concluded that we're stuck-up and rude for not answering a polite question. It doesn't help those who choose to reply, because we're sitting around wondering if we've waiting long enough. If you consider posting a question to a list without making any effort to determine whether it is on-topic or not to be a social faux pas, and therefore worthy of a mild rebuke, the longer you wait the less effective the negative reinforcement is. Even if you don't see it like that, and just want to point the poster in the right direction, there's still no advantage in waiting. But frankly, I think we're worrying too much. What exactly are we worried about? As I see it, the worst that can happen is a false negative, somebody will say "You've posted to the wrong list" and will be corrected by somebody else who says "No, you've misunderstood the question, this is the right list". No harm done.
The message should be "The people who will answer your question on python-dev are also on comp.lang.python, as well as many more (you may get a faster, and probably more complete, answer on comp.lang.python). The people on python-dev don't need to see the answer (they already know it), but the people on comp.lang.python are likely to be happy to learn it."
We don't need to make excuses for why we don't give the answer here. It's enough to give the reason -- it's off-topic for this list, which is about the development of Python. That and a pointer to the right list is, in my opinion, all we need to say. We don't need to sugar coat it -- we're all adults here. -- Steven D'Aprano

On 7/22/2010 8:22 AM, Steven D'Aprano wrote:
On Thu, 22 Jul 2010 07:02:33 pm Stephen J. Turnbull wrote:
OTOH I think as quick as possible an answer is a good idea here. It saves the intended audience the thought about whether to reply or not, and an instant, constructive answer says that somebody cares.
+1
Ditto. The sooner a person redirects a question to python-list, the sooner I will answer if I have an answer. And I do answer a lot of questions on Py-list, especially those that have sat a few hours without an answer.
I think that waiting "a day or two" as suggested by Average does nobody any good.
The only 'waiting' by anyone should be a few days by someone who posts on pylist *before* they try here for other expers. -- Terry Jan Reedy

On 22/07/2010 23:25, Terry Reedy wrote:
On 7/22/2010 8:22 AM, Steven D'Aprano wrote:
On Thu, 22 Jul 2010 07:02:33 pm Stephen J. Turnbull wrote:
OTOH I think as quick as possible an answer is a good idea here. It saves the intended audience the thought about whether to reply or not, and an instant, constructive answer says that somebody cares.
+1
Ditto. The sooner a person redirects a question to python-list, the sooner I will answer if I have an answer. And I do answer a lot of questions on Py-list, especially those that have sat a few hours without an answer.
I think that waiting "a day or two" as suggested by Average does nobody any good.
The only 'waiting' by anyone should be a few days by someone who posts on pylist *before* they try here for other expers.
If only the same principal applied on the issue tracker. Anyone fancy taking on a few orphans, allowing for the fact that you might get told off for creating noise or for offending devs who don't like being reminded of outstanding issues? Still, what's nine years to someone who's waiting for a bug fix? Kindest regards. Mark Lawrence.

Steven D'Aprano <steve@pearwood.info> writes:
We don't need to make excuses for why we don't give the answer here. It's enough to give the reason -- it's off-topic for this list, which is about the development of Python. That and a pointer to the right list is, in my opinion, all we need to say. We don't need to sugar coat it -- we're all adults here.
That's fine for people who already feel they are part of this particular community. The concern, as I understand it from earlier in the thread, is the regular only-one-opportunity-at-a-first-impression response given to someone *new to* this community, who clearly doesn't yet know the mores and expectations. In that case, it's not enough to say “we're all adults”, because we're also all human: the perceived tone of a first response we receive will strongly influence our impression of the wider community, despite any appeals one might make to the irrationality of that reaction. Asking about how Python works is a likely first step to becoming a valuable contributor later on (even if most such steps never go beyond the first), and a poor impression will surely kill most of that potential. So I do think it's worth this discussion about how to achieve the conflicting goals already mentioned — efficient communication and welcome to newcomers — and that “we don't need to sugar coat it” is incorrect for this purpose. -- \ “Working out the social politics of who you can trust and why | `\ is, quite literally, what a very large part of our brain has | _o__) evolved to do.” —Douglas Adams | Ben Finney

On Fri, 23 Jul 2010 10:59:32 am Ben Finney wrote:
Steven D'Aprano <steve@pearwood.info> writes:
We don't need to make excuses for why we don't give the answer here. It's enough to give the reason -- it's off-topic for this list, which is about the development of Python. That and a pointer to the right list is, in my opinion, all we need to say. We don't need to sugar coat it -- we're all adults here.
That's fine for people who already feel they are part of this particular community. The concern, as I understand it from earlier in the thread, is the regular only-one-opportunity-at-a-first-impression response given to someone *new to* this community, who clearly doesn't yet know the mores and expectations.
I'm not suggesting that we need to be rude. But we can give them the respect of starting off by treating them according to the mores and expectations of our community, rather than by assuming that they will immediately take offence or be frightened off, or by immediately getting defensive about the fact that this isn't a beginner's list. We have nothing to be ashamed of for wanting to keep this list for dev related issues, why make excuses for it? In other words, keep doing what we've been doing for as long as I've been subscribed to this list: answer politely but firmly that this is the wrong list, point them to the correct place, and, if the mood strikes you, give a brief answer to the question that doesn't invite a long discussion. I think that's fair and respectful. -- Steven D'Aprano

> > ...After a sufficient period of waiting, say a day or two with no response: > > Ok, I'll wait a bit longer.
I don't think that's a good idea.
My bad, I really only meant a "sufficient delay to allow the possibility of an interested party replying". I actually figured about a day.
OTOH I think as quick as possible an answer is a good idea here. It saves the intended audience the thought about whether to reply or not,
The intended audience (the python developers or other interested lurkers) hardly need to give much thought on whether or not to reply. No one on a -dev list is expected to be a tutor. To have any reply whatsoever should be considered a bestowal of time without equal merit, or gratis. Ideally, those who aren't subscribed should get an immediate, automatic reply about resources available and how to engage the community without raising the ire of same. If there's no such automatic resource, but a designated list manager, this should be sent in private so as not to engage or bother the rest of the list with canned responses, otherwise publically so as to avoid duplication of effort. To those who *are* subscribed, they probably don't need to be told. A reference or link to ESR's "How to Ask Questions The Smart Way" (http://catb.org/esr/faqs/smart-questions.html) is a pretty good inclusion also. For those who may have never heard of it, it's pretty much the authority on developer list etiquette. $0.02, Marcos

On 7/22/2010 3:29 PM, average wrote: Speacking of etiquette, it is traditional to use real names in the from field on pydev. It will get you more attention and respect.
A reference or link to ESR's "How to Ask Questions The Smart Way" (http://catb.org/esr/faqs/smart-questions.html) is a pretty good inclusion also. For those who may have never heard of it, it's pretty much the authority on developer list etiquette.
I agree
Marcos
Well, that is a start ;-) -- Terry Jan Reedy

Scott McCarty wrote:
All, I have searched everywhere (mostly the code and a little google) and I cannot understand where the SIGKILL signal gets checked when it is set as a handler.
Possibly it's not being checked at all by Python, but is being rejected by the system call. The Darwin man page says this about signal(3) in the ERRORS section: [EINVAL] An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP. Not sure why it gets reported as a RuntimeError rather than an OSError, though. -- Greg

Greg Ewing writes:
Scott McCarty wrote:
All, I have searched everywhere (mostly the code and a little google) and I cannot understand where the SIGKILL signal gets checked when it is set as a handler.
Possibly it's not being checked at all by Python, but is being rejected by the system call. The Darwin man page says this about signal(3) in the ERRORS section:
[EINVAL] An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP.
The Linux signal(2) manpage just says EINVAL signum is invalid. But I suppose that could be stretched to cover "SIGKILL, SIGSTOP, or not a signal number known to the kernel".
Not sure why it gets reported as a RuntimeError rather than an OSError, though.
My understanding of OSError is that the OS is saying "sorry, what you tried to do is perfectly reasonable under some circumstances, but you can't do that now." ENOMEM, EPERM, ENOENT etc fit this model. RuntimeError OTOH is basically saying "You should know better than to try that!" EINVAL fits this model.

On Jul 22, 2010, at 12:00 AM, Stephen J. Turnbull wrote:
My understanding of OSError is that the OS is saying "sorry, what you tried to do is perfectly reasonable under some circumstances, but you can't do that now." ENOMEM, EPERM, ENOENT etc fit this model.
RuntimeError OTOH is basically saying "You should know better than to try that!" EINVAL fits this model.
That is not my understanding of OSError at all, especially given that I have seen plenty of OSErrors that have EINVAL set by various things. OSError's docstring specifically says "OS system call failed.", and that's the way I've already understood it: you made a syscall and got some kind of error. Python _mostly_ avoids classifying OSErrors into different exception types in other APIs. The selection of RuntimeError in this particular case seems somewhat random and ad-hoc, given that out-of-range signal values give ValueError while SIGKILL and SIGSTOP give RuntimeError. The RuntimeError's args start with "22" (which I assume is supposed to mean "EINVAL") but it doesn't have an 'errno' attribute as an OSError would. The ValueError doesn't relate to an errno at all. Nowhere does the documentation say "raises OSError or ValueError or TypeError or RuntimeError whose args[0] may be an errno". To be clear, this particular area doesn't bother me. I've been dealing with weird and puzzling signal-handling issues in Python for years and years and this dusty corner of the code has never come up. I did want to reply to this particular message, though, because I *would* eventually like the exception hierarchy raised by certain stdlib functions to be more thoroughly documented and coherent, but a prerequisite to that is to avoid rationalizing the random potpourri of exception types that certain parts of the stdlib emit. I think signal.signal is one such part.

Glyph Lefkowitz wrote:
The selection of RuntimeError in this particular case seems somewhat random and ad-hoc,
Indeed -- usually a RuntimeError indicates that something concerning the internals of Python itself is screwed up, e.g. attempting to execute invalid bytecode. The fact that it turns up here may be a historical accident. I can imagine that the signal module dates back to the very early days of Python, when the conventions for error reporting were not so well formed. Maybe this is something that could be considered in the exception hierarchy revamp proposal that was posted recently? -- Greg

Greg Ewing writes:
Glyph Lefkowitz wrote:
The selection of RuntimeError in this particular case seems somewhat random and ad-hoc,
Well, I guess we'd have to catch the person who wrote the code and ask.
Maybe this is something that could be considered in the exception hierarchy revamp proposal that was posted recently?
I think that's Antoine's PEP 3151. Interestingly, he doesn't mention EINVAL at all. http://www.python.org/dev/peps/pep-3151/

On Thu, 22 Jul 2010 17:50:00 +0900 "Stephen J. Turnbull" <stephen@xemacs.org> wrote:
Greg Ewing writes:
Glyph Lefkowitz wrote:
The selection of RuntimeError in this particular case seems somewhat random and ad-hoc,
Well, I guess we'd have to catch the person who wrote the code and ask.
Maybe this is something that could be considered in the exception hierarchy revamp proposal that was posted recently?
I think that's Antoine's PEP 3151. Interestingly, he doesn't mention EINVAL at all.
That's right. It is based on a survey of existing exception-catching code in the stdlib. There's only one match in the whole Lib/ subtree: $ grep -r EINVAL Lib/ Lib/plat-sunos5/STROPTS.py:968:EINVAL = 22 I guess EINVAL would most often indicate a programming error, which is why it doesn't get handled specifically in except clauses. Semantically, EINVAL seems close to ValueError. If I search inside the man pages here, I get excerpts such as: - wait(2): EINVAL The options argument was invalid. - gettimeofday(2): EINVAL Timezone (or something else) is invalid. - socket(2): EINVAL Unknown protocol, or protocol family not available. EINVAL Invalid flags in type. - rename(2): EINVAL The new pathname contained a path prefix of the old, or, more generally, an attempt was made to make a directory a subdirectory of itself. Regards Antoine.

On 10:33 am, solipsis@pitrou.net wrote:
On Thu, 22 Jul 2010 17:50:00 +0900 "Stephen J. Turnbull" <stephen@xemacs.org> wrote:
I think that's Antoine's PEP 3151. Interestingly, he doesn't mention EINVAL at all.
That's right. It is based on a survey of existing exception-catching code in the stdlib. There's only one match in the whole Lib/ subtree:
$ grep -r EINVAL Lib/ Lib/plat-sunos5/STROPTS.py:968:EINVAL = 22
I guess EINVAL would most often indicate a programming error, which is why it doesn't get handled specifically in except clauses.
For setgroups it means you exceeded a platform-specific limit. On Windows, for non-blocking connect, it means wait a little longer. Jean-Paul

On Mon, Jul 19, 2010 at 12:11 PM, Scott McCarty <scott.mccarty@gmail.com> wrote:
All, I have searched everywhere (mostly the code and a little google) and I cannot understand where the SIGKILL signal gets checked when it is set as a handler. I have scoured the Modules/signalmodule.c only to find two instances of the RuntimeError exception, but I cannot understand how python knows when a handler is set for SIGKILL. I understand that this changed in 2.4 and I am not trying to change it, I just really want to understand where this happens. I used grep to find SIGKILL and SIGTERM to see if I could determine where the critical difference is, but I cannot figure it out.
I have about 2 hours of searching around and I can't figure it out, I assume it has to rely on some default behaviour in Unix, but I have no idea. I don't see a difference between SIGKILL and SIGTERM in the python code, but obviously there is some difference. I understand what the difference is in Unix/Linux, I just want to see it in the python code. Since python is checking at run time to see what signals handlers are added, I know there must be a difference.
The signals get initialized at interpreter startup within the initsigs function (Python/pythonrun.c). By default the interpreter ignores SIGPIPE, SIGXFZ and SIGXFSZ. Eventually initsignal (Modules/signalmodule.c) which will loop over an array of all handlers and set their handlers to the default handler, ignore handler or None, depending on the default state of the handler as reported by the OS. After all of that python will register its own signal handler for SIGINT which raises a KeyboardInterrupt error (you can change this). By default on Linux SIGKILL gets a None handler since it can not be handled or ignored (as dictated by the OS) and SIGTERM gets the default handler which at least under Linux is to terminate the program without doing any kind of cleanup. It is worth noting that you can handle SIGTERM but python chooses not to do this by default. Doug Hellmann wrote a post about the signal module that is a good complement to the C code for understanding how signals are handled in python. http://www.doughellmann.com/PyMOTW/signal/ HTH. -mike -- Michael E. Crute http://mike.crute.org It is a mistake to think you can solve any major problem just with potatoes. --Douglas Adams
participants (18)
-
"Martin v. Löwis"
-
Alexander Belopolsky
-
Antoine Pitrou
-
average
-
Ben Finney
-
exarkun@twistedmatrix.com
-
Glyph Lefkowitz
-
Greg Ewing
-
Mark Lawrence
-
Michael Crute
-
Oleg Broytman
-
Reid Kleckner
-
Scott McCarty
-
Simon Cross
-
Stephen J. Turnbull
-
Steve Holden
-
Steven D'Aprano
-
Terry Reedy