How do I do time.sleep in certain thread in Python?

Web Servers: What are some best-practices for writing multi-thread programs with Django and Python?

  • What I'm doing is getting some photos from Foursquare and Instagram. An API(REST) call triggers Foursquare query to get 30 places. Then 30 queries are issued to Foursquare to get a photo for each place. I've implemented the second queries by threads to get 30 responses as fast as it can. My concern is that if there are several users who issue the API the response might be slow. The system is using Apache, Django(python), single machine(Rackspace 512MB). What is the best practice to implement a job which requires concurrent processing.

  • Answer:

    Use thread pool to limit number of workers. Read more about them at: http://stackoverflow.com/questions/3033952/python-thread-pool-similar-to-the-multiprocessing-pool

Alexander Artemenko at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.