I'm trying to solve a business problem where I need to cache many images, 
around 20 at a time from a third party website on my server and then serve 
those to a client. A key requirement is that they be made available as 
quickly as possible, so for this reason I started building a function in 
Web2Py with the python multiprocessing module. I used the Process and Lock 
functions from this and got it to work fine in the web2py command line 
environment. Essentially it downloads all 20 images simultaneously, stores 
them to disk, and updates my DB with their location. However, when I call 
the function from my controller after a web request, I get lots of errors 
such as this one:

<class 'gluon.contrib.pg8000.errors.InternalError'>(Unexpected response msg 
> <gluon.contrib.pg8000.protocol.BindComplete object at 0x7fd2f4513150>)


I know spawning processes is frowned upon in Web2py, so I also tried the 
Scheduler. While I could get that to work, I found the delay waiting for 
the heartbeat to cycle around to be a hindrance - even 1 second is too long 
to wait to start the caching process. The only way I have been able to get 
it to work is to download one file after the other with urllib, but I 
really need to be able to grab them all simulatenously, and launch the 
processes that grab them instantaneously. Is there a solution to this 
problem using Web2py?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to