Errang Genevre
asked on
Best practices for multi-threading in Python
Hello,
I'm fairly new to Python; and I'm trying to find some resources that properly explains how to structure a multi-threaded Python project. This will be running in GNU/Linux.
My main concern is that I have a dictionary that needs to be read by all the threads; would it be possible to access the dictionary in each thread without explicitly passing the variable into each thread?
Also, I would need to write into multiple files; would it be better to have one thread that accesses these files, or is Python/Unix smart enough to allow one thread to finish writing the entire line before another thread jumps in to write something?
Appreciate any advice on this!
I'm fairly new to Python; and I'm trying to find some resources that properly explains how to structure a multi-threaded Python project. This will be running in GNU/Linux.
My main concern is that I have a dictionary that needs to be read by all the threads; would it be possible to access the dictionary in each thread without explicitly passing the variable into each thread?
Also, I would need to write into multiple files; would it be better to have one thread that accesses these files, or is Python/Unix smart enough to allow one thread to finish writing the entire line before another thread jumps in to write something?
Appreciate any advice on this!
ASKER
And import it into the multi threaded process?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
Can use use a global variable for the dictionary?