python - execute functions in a queue -


I have an example, which should show me what I want to do

  Queue = 2 df function (): print 'abcd' time sleep (3) def exec_times (time): #de some function () def exec_queue (queue): #de some functions () exec_times (3) #things while working This function is required to wait for the Finnish time. Sleep (10)  

should be the result

  abcd abcd # after the first two execution functions abcd  

Is there a way to do this without using a trahed?

I mean some gibb function to do this work.

If you want to avoid threads, one option is to use multiple processes if you want to fire on dragon 2.6 If so, take a look at the module. If Python 2.5, then see.

Note in docs for multiprocessing, which takes care of your needs:

One can create a pool of processes which

class Multiprocessing. Pool ([processes, beginner [, initargs [, maxtasksperchild]]]])

A process pool object that controls a pool of worker processes in which the task can be presented. This supports asynchronous results with timeout and callback and a parallel map implementation.


Comments