Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is straight from the python documentation: <a href="http://docs.python.org/2/library/multiprocessing.html" rel="nofollow">http://docs.python.org/2/library/multiprocessing.html</a></p> <pre><code>from multiprocessing import Process, Pipe def f(conn): conn.send([42, None, 'hello']) conn.close() if __name__ == '__main__': parent_conn, child_conn = Pipe() p = Process(target=f, args=(child_conn,)) p.start() print parent_conn.recv() # prints "[42, None, 'hello']" p.join() </code></pre> <p>I've had better results using shared state. Especially for simple data like temperature (a number I assume - not a complex custom object or whatever) Here is a wee example (again you will find more in the python docs)</p> <pre><code>#import stuff from multiprocessing import Process, Manager # Create a shared dictionary of paremeters for both processes to use manager = Manager() global_props = manager.dict() # SuperImportant - initialise all parameters first!! global_props.update({'temp': 21.3}) def functionOne(global_props): # Do some stuff read temperature global_props['temp'] = newVal def functionTwo(global_props): temp = global_props['temp'] # Do some stuff with the new value # assign listeners to the two processes, passing in the properties dictionary handlerOne = functionOne # This can also be a class in which case it calls __init__() handlerTwo = functionTwo processOne = Process(target=handlerOne, args=(global_props)) processTwo = Process(target=handlerTwo, args=(global_props)) # Start the processes running... processOne.start() processTwo.start() processOne.join() processTwo.join() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload