threading
and multiprocessing
are the modules that provide concurency facility in python. Both provide different utility.
Google the difference to know more. But basically threading
provides multiple threads (in a single process-context).
This can you computing teeth while your data gets loaded. Although multiple threads can be started with this but only
1 thread can be active at a time. Other threads can be sleeping or loading data. Thus, this is not suitable when your
threads need to all do number crunching (CPU-bound).
multiprocessing
lets you create separate processes.
These processes have different memory context. Data needs to be shared with semaphores. Easy way share data is using the
Manager
class and Manager.list()
and Manager.dict()
or the multiprocessing.Queues()
.