Google Groups

Threads with homemade task queues

David Phillips May 18, 2012 1:02 PM
Posted in group: web2py-users
I've read hearty admonishments on this forum against creating threads in controller and model files, but what about the case of a background job launched as a separate process – like what chapter four of the book calls homemade task queues and chapter eight calls a background task? 

My application has a long-running job that make frequent, periodic http requests. After struggling with various approaches, I've finally got a prototype algorithm working efficiently and correctly that makes synchronous, parallel http request in a number of worker threads. I could probably run my code as a separate, non-web2py python script, but it would be convenient to be able to access the model.

Do the reasons for not running creating threads inside controllers still apply in the case of a separate background process?