Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Forking with python

  1. Feb 20, 2009 #1

    daniel_i_l

    User Avatar
    Gold Member

    For some reasons, if I fork a proccess (or start a thread) in python and let the original program wait for user input, the the forked proccess doesn't print anything to the screen untill the newline character is printed. For example (i used '----' instead of indent):
    doesn't print any thing to the screen. But if the 3rd line is instead
    print 'test' (without comma)
    then it does.
    Why is this?
    Thanks
     
  2. jcsd
  3. Feb 26, 2009 #2
    I'm no expert in this, but this reminds me of mutex situation.

    Often in programs, different threads or processes use the same memory, so in order to avoid corruption, when a piece of code accesses this memory, it locks it to other code until its done.

    This sounds exactly to be the case with your console you are running your code on. Threads and processes need to wait their turn, but I could be wrong, but to me this most likely seems to be the case.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Forking with python
  1. Error on Python (Replies: 9)

  2. Chess with Python (Replies: 2)

  3. Is Python the future? (Replies: 10)

  4. Python installation (Replies: 10)

Loading...