Simulate `bash` behaviour using Python and named pipes.

MRAB python at mrabarnett.plus.com
Mon Aug 5 18:42:57 EDT 2013


On 05/08/2013 22:47, Luca Cerone wrote:
>> You're back to using separate threads for the reader and the writer.
>>
> And how do I create separate threads in Python? I was trying to use the threading library without not too success..
>
To run a function in a separate thread:

import threading

def my_func(arg_1, arg_2):
     ...

my_thread = threading.Thread(target=my_func, args=(arg_1, arg_2))
my_thread.start()


Is the thread still running?

if my_thread.is_alive():
     ...


Wait for the thread to terminate:

my_thread.join()




More information about the Python-list mailing list