naive misuse?

Discussion in 'Python' started by johan2sson@gmail.com, Aug 28, 2006.

  1. Guest

    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
     
    , Aug 28, 2006
    #1
    1. Advertisements

  2. Guest

    Re: naive misuse? (of PyThreadState_SetAsyncExc)

    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
     
    , Aug 28, 2006
    #2
    1. Advertisements

  3. Tim Peters Guest

    Re: naive misuse? (of PyThreadState_SetAsyncExc)

    []
    >> 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/guide/misc/threadPrimitiveDeprecation.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).
     
    Tim Peters, Aug 29, 2006
    #3
  4. Simon Forman Guest

    Re: naive misuse? (of PyThreadState_SetAsyncExc)

    wrote:
    > 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
     
    Simon Forman, Aug 29, 2006
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon North
    Replies:
    0
    Views:
    392
    Simon North
    Aug 5, 2004
  2. Peter Flynn
    Replies:
    2
    Views:
    469
    Peter Flynn
    Aug 9, 2004
  3. Michael Laplante

    Page won't validate -- misuse of A element?

    Michael Laplante, May 18, 2006, in forum: HTML
    Replies:
    3
    Views:
    509
    Jonathan N. Little
    May 18, 2006
  4. John Roth

    Re: Misuse of <tab>

    John Roth, Jul 30, 2003, in forum: Python
    Replies:
    8
    Views:
    404
    Robin Munn
    Aug 12, 2003
  5. Michael Sampson

    Re: Misuse of <tab>

    Michael Sampson, Jul 30, 2003, in forum: Python
    Replies:
    5
    Views:
    384
    Ben Finney
    Jul 31, 2003
Loading...

Share This Page