#14433 closed (fixed)
Thread safety problem in contrib.sitemaps
Reported by: | Gabriel Hurley | Owned by: | Gabriel Hurley |
---|---|---|---|
Component: | Contrib apps | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Since sitemaps are global objects, setting self.request on the object is thread-unsafe. Reported here by Justin Bronn.
Attachments (1)
Change History (7)
by , 14 years ago
Attachment: | 14433.diff added |
---|
comment:1 by , 14 years ago
Has patch: | set |
---|---|
Status: | new → assigned |
I believe this patch should restore thread safety by passing site as an argument rather than storing request on the Sitemap object. It is as backwards-compatible as possible, since prior to [13980] the get_urls
method simply called Site.objects.get_current()
directly, so this patch uses that behavior as a fallback for anyone who may have written custom view code which does not pass in a site as an argument.
comment:2 by , 14 years ago
Thanks Gabriel. I will commit with changes:
- added tests for raising ImproperlyConfigured (and then added an import and some other logic that made the tests pass - hurray for TDD :-)
- used keyword arguments in to Sitemap.get_urls() instead of positional, in django/contrib/sitemaps/views.py and django/contrib/gis/sitemaps/views.py
I am unable to run the GIS testsuite (see #14439), so I have not checked that the GIS sections are correct, but they look correct are (hopefully) trivial.
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:4 by , 14 years ago
comment:5 by , 14 years ago
I knew the patch wasn't finished, but I had to run out the door. I wanted to give Justin or someone else who could run the GIS suite a chance to look at it. All the same, thanks for wrapping it up Luke.
Restores thread-safety to contrib.sitemaps