[Checkins] SVN: zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/ Handle situation where a bucket cannot be accessed.
satchit@zope.com
cvs-admin at zope.org
Fri Jun 15 19:18:52 UTC 2012
Log message for revision 126869:
Handle situation where a bucket cannot be accessed.
Changed:
U zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/README.txt
U zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/__init__.py
-=-
Modified: zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/README.txt
===================================================================
--- zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/README.txt 2012-06-15 16:48:01 UTC (rev 126868)
+++ zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/README.txt 2012-06-15 19:18:48 UTC (rev 126869)
@@ -96,7 +96,7 @@
import zc.s3uploadqueue
stop = zc.s3uploadqueue.process('queue.cfg')
- stop()
+ if stop: stop()
.. -> src
@@ -163,5 +163,17 @@
processing '2012-06-14%2F01.txt'
>>> urllib.unquote = orig_unquote
+
+If there's an error getting the S3 bucket, an exception will be printed.
+
+ >>> def foo(self, s):
+ ... raise Exception('some error accessing an S3 bucket.')
+ >>> boto.s3.connection.S3Connection.return_value.get_bucket.side_effect = foo
+ >>> write('/'.join(['test', name.strip()]), '')
+ >>> exec src
+ >>> show_log()
+ zc.s3uploadqueue ERROR
+ Error accessing bucket: 'testbucket'
+
>>> handler.uninstall()
Modified: zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/__init__.py
===================================================================
--- zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/__init__.py 2012-06-15 16:48:01 UTC (rev 126868)
+++ zc.s3uploadqueue/trunk/src/zc/s3uploadqueue/__init__.py 2012-06-15 19:18:48 UTC (rev 126869)
@@ -51,12 +51,7 @@
nthreads = int(options['Queue'].get('threads', 9))
poll_interval = int(options['Queue'].get('poll-interval', 9))
- def process_queue():
- conn = boto.s3.connection.S3Connection(
- options['Credentials']['aws_access_key_id'],
- options['Credentials']['aws_secret_access_key'],
- )
- bucket = conn.get_bucket(options['Queue']['bucket'])
+ def process_queue(bucket):
key = boto.s3.key.Key(bucket)
while 1:
@@ -75,8 +70,19 @@
finally:
queue.task_done()
- threads = [zc.thread.Thread(process_queue) for i in range(nthreads)]
running = [1]
+ threads = []
+ for i in range(nthreads):
+ conn = boto.s3.connection.S3Connection(
+ options['Credentials']['aws_access_key_id'],
+ options['Credentials']['aws_secret_access_key'],
+ )
+ try:
+ bucket = conn.get_bucket(options['Queue']['bucket'])
+ except Exception:
+ logger.exception('Error accessing bucket: %r', options['Queue']['bucket'])
+ return
+ threads.append(zc.thread.Thread(process_queue, args=[bucket]))
def stop():
running.pop()
More information about the checkins
mailing list