C++, Python & Threads

VUG plugin at airtel.net
Sun Mar 3 13:43:36 EST 2002


Hi all. I'm modifying Python source code in order to have more control over
threads (I need to kill threads without adding controls on them, and it
seems not to be posible). I'm modifying the function
PyThread_start_new_thread to return de PID of the thread. The modified
function is:

int PyThread_start_new_thread(void (*func)(void *), void *arg)
{
     long rv;
     int success = 0;

     dprintf(("%ld: PyThread_start_new_thread called\n",
PyThread_get_thread_ident()));

     if (!initialized)
          PyThread_init_thread();
    rv =_beginthread(func, 0, arg); /* use default stack size */

    if (rv != -1) {
      success = 1;
      printf("%ld: PyThread_start_new_thread succeeded: %ld\n",
PyThread_get_thread_ident(), rv);

      printf("PID: %d\n", rv);
     }
  return success;
}

When I launch python console and I create a thread I get a NUMBER but......
This number doesn't the same as the one I get by the function
thread.get_ident(). What's wrong in the code?

Thanks
--vug





More information about the Python-list mailing list