Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > naive misuse?

Reply
Thread Tools

naive misuse?

 
 
johan2sson@gmail.com
Guest
Posts: n/a
 
      08-27-2006
The documentation for PyThreadState_SetAsyncExc says "To prevent naive
misuse, you must write your own C extension to call this". Anyone care
to list a few examples of such naive misuse?

Johan

 
Reply With Quote
 
 
 
 
johan2sson@gmail.com
Guest
Posts: n/a
 
      08-28-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> The documentation for PyThreadState_SetAsyncExc says "To prevent naive
> misuse, you must write your own C extension to call this". Anyone care
> to list a few examples of such naive misuse?


No? I'll take that then as proof that it's impossible to misuse the
function.

Thanks,
Johan

 
Reply With Quote
 
 
 
 
Tim Peters
Guest
Posts: n/a
 
      08-28-2006
[(E-Mail Removed)]
>> The documentation for PyThreadState_SetAsyncExc says "To prevent naive
>> misuse, you must write your own C extension to call this". Anyone care
>> to list a few examples of such naive misuse?


[and again]
> No? I'll take that then as proof that it's impossible to misuse the
> function.


That's wise Stopping a thread asynchronously is in /general/ a
dangerous thing to do, and for obvious reasons. For example, perhaps
the victim thread is running in a library routine at the time the
asynch exception is raised, and getting forcibly ejected from the
normal control flow leaves a library-internal mutex locked forever.
Or perhaps a catch-all "finally:" clause in the library manages to
release the mutex, but leaves the internals in an inconsistent state.
Etc. The same kinds of potential disasters accout for why Java
deprecated its versions of this gimmick:

http://java.sun.com/j2se/1.3/docs/gu...precation.html

That said, you can invoke PyThreadState_SetAsyncExc() from Python
using the `ctypes` module (which will be included in 2.5, and is
available as an extension module for earlier Pythons).
 
Reply With Quote
 
Simon Forman
Guest
Posts: n/a
 
      08-29-2006

(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
> > The documentation for PyThreadState_SetAsyncExc says "To prevent naive
> > misuse, you must write your own C extension to call this". Anyone care
> > to list a few examples of such naive misuse?

>
> No? I'll take that then as proof that it's impossible to misuse the
> function.
>
> Thanks,
> Johan


I *was* going to say that if you didn't already know the answer to that
question then your use would almost certainly be naive. But I thought
that'd be more nasty than funny, so I bit my tongue.

~Simon

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naive question about dialling codes on VOIP usenet@isbd.co.uk UK VOIP 11 01-20-2006 07:23 PM
Naive question: Crystal reports in ASP.NET =?Utf-8?B?a2Q=?= ASP .Net 1 05-28-2005 02:23 PM
Hi, bit naive, but could you suggest me an undergrad. project in XML tech. Waqas XML 5 11-15-2004 02:47 PM
Naive question on megapixels Ed Johnson Digital Photography 16 12-06-2003 03:45 AM
naive operator new question Frederic C++ 0 07-03-2003 05:17 PM



Advertisments