Parallel computing with Python
Question: here is the code of my python script:

    
    
      import time
      for j in range(1,150,1):
            for i in range(1,5,1):    
               x = j + i
               print(x)
               time.sleep(180)
    

This script is started out of my Finite Element programm which can be
manipulated by python. If i start this script it starts to run, but if the
call time.sleep is activated the Finite Element program also stops working.
The main task of the script shall be to start print 5 times "x" stop the
script for a certain time and print 5 times "x" again. Instead of "print"
another command is used in the final program. The stopping of the FE program
has to avoided. How can i manage that? I already tried different things, e.g.
threading, but that doesn't work too. Do you mean the problem can be solved by
using parallel processes? Thanks for your suggestions.


Answer: Do you intend to do something like this:

    
    
    #! /usr/bin/env python
    
    import threading
    import time
    
    class Worker (threading.Thread):
        def run (self):
            for j in range(1,150,1):
                for i in range(1,5,1):
                    x = j + i
                    print "Worker says: %d" % x
                time.sleep (5)
    
    if __name__ == '__main__':
        Worker ().start ()
        for i in range (1, 100):
            print "Main thread says: I am running."
            time.sleep (1)
    

