I have a python application that grabs a collection of data and for each piece of data in that collection it performs a task. The task takes some time to complete as there i
You might consider looking into Stackless Python. If you have control over the function that takes a long time, you can just throw some stackless.schedule()
s in there (saying yield to the next coroutine), or else you can set Stackless to preemptive multitasking.
In Stackless, you don't have threads, but tasklets or greenlets which are essentially very lightweight threads. It works great in the sense that there's a pretty good framework with very little setup to get multitasking going.
However, Stackless hinders portability because you have to replace a few of the standard Python libraries -- Stackless removes reliance on the C stack. It's very portable if the next user also has Stackless installed, but that will rarely be the case.