本文整理匯總了Python中boto.emr.connection.EmrConnection.close方法的典型用法代碼示例。如果您正苦於以下問題:Python EmrConnection.close方法的具體用法?Python EmrConnection.close怎麽用?Python EmrConnection.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類boto.emr.connection.EmrConnection
的用法示例。
在下文中一共展示了EmrConnection.close方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from boto.emr.connection import EmrConnection [as 別名]
# 或者: from boto.emr.connection.EmrConnection import close [as 別名]
class Rankmaniac:
"""
(wrapper class)
This class presents a simple wrapper around the AWS SDK. It strives
to provide all the functionality required to run map-reduce
(Hadoop) on Amazon. This way the students do not need to worry about
learning the API for Amazon S3 and EMR, and instead can focus on
computing pagerank quickly!
"""
DefaultRegionName = 'us-west-2'
DefaultRegionEndpoint = 'elasticmapreduce.us-west-2.amazonaws.com'
def __init__(self, team_id, access_key, secret_key,
bucket='cs144students'):
"""
(constructor)
Creates a new instance of the Rankmaniac class for a specific
team using the provided credentials.
Arguments:
team_id <str> the team identifier, which may be
differ slightly from the actual team
name.
access_key <str> the AWS access key identifier.
secret_key <str> the AWS secret acess key.
Keyword arguments:
bucket <str> the S3 bucket name.
"""
region = RegionInfo(None, self.DefaultRegionName,
self.DefaultRegionEndpoint)
self._s3_bucket = bucket
self._s3_conn = S3Connection(access_key, secret_key)
self._emr_conn = EmrConnection(access_key, secret_key, region=region)
self.team_id = team_id
self.job_id = None
self._reset()
self._num_instances = 1
def _reset(self):
"""
Resets the internal state of the job and submission.
"""
self._iter_no = 0
self._infile = None
self._last_outdir = None
self._last_process_step_iter_no = -1
self._is_done = False
def __del__(self):
"""
(destructor)
Terminates the map-reduce job if any, and closes the connections
to Amazon S3 and EMR.
"""
if self.job_id is not None:
self.terminate()
self._s3_conn.close()
self._emr_conn.close()
def __enter__(self):
"""
Used for `with` syntax. Simply returns this instance since the
set-up has all been done in the constructor.
"""
return self
def __exit__(self, type, value, traceback):
"""
Refer to __del__().
"""
self.__del__()
return False # do not swallow any exceptions
def upload(self, indir='data'):
"""
Uploads the local data to Amazon S3 under the configured bucket
and key prefix (the team identifier). This way the code can be
accessed by Amazon EMR to compute pagerank.
Keyword arguments:
indir <str> the base directory from which to
upload contents.
Special notes:
#.........這裏部分代碼省略.........