RE: Please help with Threading

Discussion in 'Python' started by Carlos Nepomuceno, May 20, 2013.

  1. ----------------------------------------
    > Date: Sun, 19 May 2013 13:10:36 +1000
    > From:
    > To:
    > CC:
    > Subject: Re: Please help with Threading
    > On 19May2013 03:02, Carlos Nepomuceno <> wrote:
    > | Just been told that GIL doesn't make things slower, but as I
    > | didn't know that such a thing even existed I went out looking for
    > | more info and found that document:
    > |
    > |
    > | Is it current? I didn't know Python threads aren't preemptive.
    > | Seems to be something really old considering the state of the art
    > | on parallel execution on multi-cores.
    > | What's the catch on making Python threads preemptive? Are there any ongoing projects to make that?
    > Depends what you mean by preemptive. If you have multiple CPU bound
    > pure Python threads they will all get CPU time without any of them
    > explicitly yeilding control. But thread switching happens between
    > python instructions, mediated by the interpreter.

    I meant operating system preemptive. I've just checked and Python does not start Windows threads.

    > The standard answers for using multiple cores is to either run
    > multiple processes (either explicitly spawning other executables,
    > or spawning child python processes using the multiprocessing module),
    > or to use (as suggested) libraries that can do the compute intensive
    > bits themselves, releasing the while doing so so that the Python
    > interpreter can run other bits of your python code.

    I've just discovered the multiprocessing module[1] and will make some testswith it later. Are there any other modules for that purpose?

    I've found the following articles about Python threads. Any suggestions?


    > Plenty of OS system calls (and calls to other libraries from the
    > interpreter) release the GIL during the call. Other python threads
    > can run during that window.
    > And there are other Python implementations other than CPython.
    > Cheers,
    > --
    > Cameron Simpson <>
    > Processes are like potatoes. - NCR device driver manual
    Carlos Nepomuceno, May 20, 2013
    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. KK
    Big Brian
    Oct 14, 2003
  2. Replies:
    Mark Space
    Dec 29, 2007
  3. silkenpy
    Dennis Lee Bieber
    Feb 15, 2008
  4. Steven Woody
    Steven Woody
    Jan 9, 2009
  5. Steven Woody
    Steven Woody
    Jan 9, 2009

Share This Page