Asynchronously retrieving information from a process
Question: Here is the pseudo code for what I want to do.

    
    
    import time
    
    def run():
    
        while x < 10000000:
            x += 1
    
    if __name__ == "__main__":
    
        p = Process(run)
        p.start()
    
        time.sleep(3)
    
        #some code that I don't know that will give me the current value of x
    

Pythons `threading` module seems to be the way to go however I have yet to
successfully implement this example.


Answer: Everything you need is in the `multiprocessing`
[module](http://docs.python.org/library/multiprocessing.html). Perhaps a
[shared memory](http://docs.python.org/library/multiprocessing.html#sharing-
state-between-processes) object would help here?

Note that threading in Python is affected by the [Global Interpreter
Lock](http://wiki.python.org/moin/GlobalInterpreterLock), which essentially
prevents multithreaded Python code.

