Merge "Make pending_timeout an argument of __init__"
This commit is contained in:
commit
e10c8bfde9
|
@ -118,10 +118,12 @@ class AccountController(object):
|
|||
request=req)
|
||||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_account_broker(drive, part, account)
|
||||
if container: # put account container
|
||||
pending_timeout = None
|
||||
if 'x-trans-id' in req.headers:
|
||||
broker.pending_timeout = 3
|
||||
pending_timeout = 3
|
||||
broker = self._get_account_broker(drive, part, account,
|
||||
pending_timeout=pending_timeout)
|
||||
if account.startswith(self.auto_create_account_prefix) and \
|
||||
not os.path.exists(broker.db_file):
|
||||
try:
|
||||
|
@ -142,6 +144,7 @@ class AccountController(object):
|
|||
else:
|
||||
return HTTPCreated(request=req)
|
||||
else: # put account
|
||||
broker = self._get_account_broker(drive, part, account)
|
||||
timestamp = normalize_timestamp(req.headers['x-timestamp'])
|
||||
if not os.path.exists(broker.db_file):
|
||||
try:
|
||||
|
@ -189,8 +192,8 @@ class AccountController(object):
|
|||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_account_broker(drive, part, account,
|
||||
pending_timeout=0.1,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
if broker.is_deleted():
|
||||
return self._deleted_response(broker, req, HTTPNotFound)
|
||||
info = broker.get_info()
|
||||
|
@ -238,8 +241,8 @@ class AccountController(object):
|
|||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_account_broker(drive, part, account,
|
||||
pending_timeout=0.1,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
if broker.is_deleted():
|
||||
return self._deleted_response(broker, req, HTTPNotFound)
|
||||
return account_listing_response(account, req, out_content_type, broker,
|
||||
|
|
|
@ -173,13 +173,13 @@ class DatabaseBroker(object):
|
|||
"""Encapsulates working with a database."""
|
||||
|
||||
def __init__(self, db_file, timeout=BROKER_TIMEOUT, logger=None,
|
||||
account=None, container=None, pending_timeout=10,
|
||||
account=None, container=None, pending_timeout=None,
|
||||
stale_reads_ok=False):
|
||||
"""Encapsulates working with a database."""
|
||||
self.conn = None
|
||||
self.db_file = db_file
|
||||
self.pending_file = self.db_file + '.pending'
|
||||
self.pending_timeout = pending_timeout
|
||||
self.pending_timeout = pending_timeout or 10
|
||||
self.stale_reads_ok = stale_reads_ok
|
||||
self.db_dir = os.path.dirname(db_file)
|
||||
self.timeout = timeout
|
||||
|
@ -928,8 +928,8 @@ class ContainerBroker(DatabaseBroker):
|
|||
if pending_size > PENDING_CAP:
|
||||
self._commit_puts([record])
|
||||
else:
|
||||
with lock_parent_directory(
|
||||
self.pending_file, self.pending_timeout):
|
||||
with lock_parent_directory(self.pending_file,
|
||||
self.pending_timeout):
|
||||
with open(self.pending_file, 'a+b') as fp:
|
||||
# Colons aren't used in base64 encoding; so they are our
|
||||
# delimiter
|
||||
|
|
|
@ -311,8 +311,8 @@ class ContainerController(object):
|
|||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_container_broker(drive, part, account, container,
|
||||
pending_timeout=0.1,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
if broker.is_deleted():
|
||||
return HTTPNotFound(request=req)
|
||||
info = broker.get_info()
|
||||
|
@ -399,8 +399,8 @@ class ContainerController(object):
|
|||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_container_broker(drive, part, account, container,
|
||||
pending_timeout=0.1,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
if broker.is_deleted():
|
||||
return HTTPNotFound(request=req)
|
||||
info = broker.get_info()
|
||||
|
|
Loading…
Reference in New Issue