[Python-3000] improved threading in py3k (original) (raw)

Josiah Carlson jcarlson at uci.edu
Fri Aug 4 21:29:09 CEST 2006


"tomer filiba" <tomerfiliba at gmail.com> wrote:

> [...] it could be implemented as a debugging trace function even if it could be, why? you can't really suggest that from now on, every multithreaded app must run in trace mode, right? it's a performance penalty for no good reason -- it's a question of API.

You can remove the performance penalty by resetting the trace function to None.

just as the API lets you create threads, it should allow you to kill them, once you decide so. your code shouldn't rely on the "cooperativeness" of other functions (i.e., the thread does blocking IO using some external library, but you wish to stop it after some timeout, etc.).

According to recent unrelated research with regards to the Win32 API, most thread killing methods (if not all?) leaves the thread state broken in such a way that the only way to fix it is to close down the process. Then again, I could be misremembering, the Win32 API is huge.

all i was talking about was adding a new function to the thread module, as well as a new builtin exception to completement it. it's no such a big change that you should work extra hours in inventing creative workarounds for.

It took me 5 minutes to generate that possible solution and a test for it. I wasn't saying that the functionality was generally undesireable, just that I believed it should be possible in pure Python today (rather than waiting for Py3k as is the implication by your posting in the Py3k mailing list), and showing why it couldn't be done today. It also brings up the implied question as to whether non-mainthreads should actually execute trace functions.

you said: > Already exists as sys.exit()

but i said: >> it would also allow you to ensure the interpreter is killed, as SystemExit >> can be caught by external code against your will. please take the time to read my post before you reply. here is what i mean by "against your will":

I wasn't aware that sys.exit() raised SystemExit, as I tend to not use bare excepts or sys.exit() in my code (I prefer os._exit(), because when I want to quit, cleanup is the least of my worries). You could have said "sys.exit() raises SystemExit" and I would have understood my mistake.

I'm curious as to what I have done to deserve the rudeness of your reply.



More information about the Python-3000 mailing list