On 3/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> My most popular view looks for a memcached RSS feed, and if it doesn't
> exist, uses URLLIB2 to go out and get it (then cache it). I've read
> about possible problems with URLLIB2.openurl() that it might not free
> the socket after use. I've made sure to close all connections and
> dereference all variables/objects before the view returns. Not sure if
> this is relevant, but it seems worth mentioning. My memcached hit
> ratio is 99%, so I'm comfortable that it's not opening a connection
> too often.

I'm not sure this will fix your problem, but, as an aside, I'd suggest
that you not perform HTTP requests (using urllib2 or any other
library) from within a view. It's generally just not a good thing to
do, because it makes your site's performance dependent on the
performance of another Web site that's out of your control. A better
solution would be to set up a regular update of the given Web page(s)
via cron.

With that said, you could only do this sort of caching if the set of
Web pages that you're requesting is static and known ahead of time. If
you're operating a site like feedvalidator.org whose main purpose is
to retrieve Web pages dynamically and do some operations on them,
you're stuck making the requests from within the view.

Anyway, hope this helps.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to