Skip to content

Commit

Permalink
Adding _Future type for storage batches.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Apr 9, 2015
1 parent fafb25c commit c024bf1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions gcloud/storage/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,40 @@ class NoContent(object):
status = 204


class _Future(object):
"""Class to hold a future value for a deferred request.
Used by for requests that get sent in a :class:`Batch`.
"""

def __init__(self):
self._value = None

def get_value(self):
"""Gets the value associated with the future.
:rtype: object
:returns: The future value that was set.
:raises: :class:`ValueError` if the value has not been set.
"""
if self._value is None:
raise ValueError('Future value is unset.')
return self._value

def set_value(self, value):
"""Sets the value associated with the future.
:type value: object
:param value: The future value that was set.
:raises: :class:`ValueError` if the value is already set.
"""
if self._value is None:
self._value = value
else:
raise ValueError('Future value is already set.')


class Batch(Connection):
"""Proxy an underlying connection, batching up change operations.
Expand Down

0 comments on commit c024bf1

Please sign in to comment.