Removed a bunch of annoying trailing whitespace.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5068 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
76005c917f
commit
535535a45e
|
@ -86,7 +86,7 @@ def patch_response_headers(response, cache_timeout=None):
|
||||||
|
|
||||||
def add_never_cache_headers(response):
|
def add_never_cache_headers(response):
|
||||||
"""
|
"""
|
||||||
Add headers to a response to indicate that
|
Add headers to a response to indicate that
|
||||||
a page should never be cached.
|
a page should never be cached.
|
||||||
"""
|
"""
|
||||||
patch_response_headers(response, cache_timeout=-1)
|
patch_response_headers(response, cache_timeout=-1)
|
||||||
|
|
|
@ -16,9 +16,9 @@ class MergeDict(object):
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
return self.has_key(key)
|
return self.has_key(key)
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
return self.__class__(*self.dicts)
|
return self.__class__(*self.dicts)
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
try:
|
try:
|
||||||
|
@ -45,9 +45,9 @@ class MergeDict(object):
|
||||||
if dict.has_key(key):
|
if dict.has_key(key):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
""" returns a copy of this object"""
|
""" returns a copy of this object"""
|
||||||
return self.__copy__()
|
return self.__copy__()
|
||||||
|
|
||||||
class SortedDict(dict):
|
class SortedDict(dict):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""
|
"""
|
||||||
Synchronization primitives:
|
Synchronization primitives:
|
||||||
|
|
||||||
- reader-writer lock (preference to writers)
|
- reader-writer lock (preference to writers)
|
||||||
|
|
||||||
(Contributed to Django by eugene@lazutkin.com)
|
(Contributed to Django by eugene@lazutkin.com)
|
||||||
|
@ -14,17 +14,16 @@ except ImportError:
|
||||||
class RWLock:
|
class RWLock:
|
||||||
"""
|
"""
|
||||||
Classic implementation of reader-writer lock with preference to writers.
|
Classic implementation of reader-writer lock with preference to writers.
|
||||||
|
|
||||||
Readers can access a resource simultaneously.
|
Readers can access a resource simultaneously.
|
||||||
Writers get an exclusive access.
|
Writers get an exclusive access.
|
||||||
|
|
||||||
API is self-descriptive:
|
API is self-descriptive:
|
||||||
reader_enters()
|
reader_enters()
|
||||||
reader_leaves()
|
reader_leaves()
|
||||||
writer_enters()
|
writer_enters()
|
||||||
writer_leaves()
|
writer_leaves()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.mutex = threading.RLock()
|
self.mutex = threading.RLock()
|
||||||
self.can_read = threading.Semaphore(0)
|
self.can_read = threading.Semaphore(0)
|
||||||
|
@ -33,7 +32,7 @@ class RWLock:
|
||||||
self.active_writers = 0
|
self.active_writers = 0
|
||||||
self.waiting_readers = 0
|
self.waiting_readers = 0
|
||||||
self.waiting_writers = 0
|
self.waiting_writers = 0
|
||||||
|
|
||||||
def reader_enters(self):
|
def reader_enters(self):
|
||||||
self.mutex.acquire()
|
self.mutex.acquire()
|
||||||
try:
|
try:
|
||||||
|
@ -45,7 +44,7 @@ class RWLock:
|
||||||
finally:
|
finally:
|
||||||
self.mutex.release()
|
self.mutex.release()
|
||||||
self.can_read.acquire()
|
self.can_read.acquire()
|
||||||
|
|
||||||
def reader_leaves(self):
|
def reader_leaves(self):
|
||||||
self.mutex.acquire()
|
self.mutex.acquire()
|
||||||
try:
|
try:
|
||||||
|
@ -56,7 +55,7 @@ class RWLock:
|
||||||
self.can_write.release()
|
self.can_write.release()
|
||||||
finally:
|
finally:
|
||||||
self.mutex.release()
|
self.mutex.release()
|
||||||
|
|
||||||
def writer_enters(self):
|
def writer_enters(self):
|
||||||
self.mutex.acquire()
|
self.mutex.acquire()
|
||||||
try:
|
try:
|
||||||
|
@ -68,7 +67,7 @@ class RWLock:
|
||||||
finally:
|
finally:
|
||||||
self.mutex.release()
|
self.mutex.release()
|
||||||
self.can_write.acquire()
|
self.can_write.acquire()
|
||||||
|
|
||||||
def writer_leaves(self):
|
def writer_leaves(self):
|
||||||
self.mutex.acquire()
|
self.mutex.acquire()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue