diff options
Diffstat (limited to 'swiftclient/service.py')
-rw-r--r-- | swiftclient/service.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py index bebe551..1b591d3 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -434,7 +434,7 @@ class SwiftService(object): }) return res except ClientException as err: - if err.http_status == 404: + if err.http_status != 404: res.update({ 'success': False, 'error': err @@ -1176,6 +1176,12 @@ class SwiftService(object): else: options = self._options + try: + segment_size = int(0 if options['segment_size'] is None else + options['segment_size']) + except ValueError: + raise SwiftError('Segment size should be an integer value') + # Does the account exist? account_stat = self.stat(options=options) if not account_stat["success"]: @@ -1196,7 +1202,14 @@ class SwiftService(object): ) ] - if options['segment_size'] is not None: + # wait for first container job to complete before possibly attempting + # segment container job because segment container job may attempt + # to HEAD the first container + for r in interruptable_as_completed(create_containers): + res = r.result() + yield res + + if segment_size: seg_container = container + '_segments' if options['segment_container']: seg_container = options['segment_container'] @@ -1205,23 +1218,23 @@ class SwiftService(object): # rather than just letting swift pick the default storage # policy, we'll try to create the segments container with the # same as the upload container - create_containers.append( - self.thread_manager.object_uu_pool.submit( + create_containers = [ + self.thread_manager.container_pool.submit( self._create_container_job, seg_container, policy_source=container ) - ) + ] else: - create_containers.append( - self.thread_manager.object_uu_pool.submit( + create_containers = [ + self.thread_manager.container_pool.submit( self._create_container_job, seg_container, headers=policy_header ) - ) + ] - for r in interruptable_as_completed(create_containers): - res = r.result() - yield res + for r in interruptable_as_completed(create_containers): + res = r.result() + yield res # We maintain a results queue here and a separate thread to monitor # the futures because we want to get results back from potential |