You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/01/24 21:37:22 UTC

[GitHub] [beam] pabloem commented on a change in pull request #16526: [WIP][BEAM-13051][C] Enable pylint warnings (misplaced-bare-raise/no-member)

pabloem commented on a change in pull request #16526:
URL: https://github.com/apache/beam/pull/16526#discussion_r791170279



##########
File path: sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py
##########
@@ -267,10 +267,10 @@ def create_stream(self, stream_name):
         )
         time.sleep(2)
         break
-      except:  # pylint: disable=bare-except
+      except Exception as e:
         if i == retries - 1:
           logging.error('Could not create kinesis stream')
-          raise
+          raise e

Review comment:
       lgtm

##########
File path: sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py
##########
@@ -290,7 +290,7 @@ def get_first_shard_id(self, stream_name):
       time.sleep(2)
       if i == retries - 1:
         logging.error('Could not initialize kinesis stream')
-        raise
+        raise RuntimeError()

Review comment:
       ```suggestion
           raise RuntimeError("Unable to initialize Kinesis Stream %s. Status: %s",
               stream['StreamDescription']['StreamName'], stream['StreamDescription']['StreamStatus'])
   ```

##########
File path: sdks/python/apache_beam/runners/common.py
##########
@@ -1262,7 +1262,7 @@ def finalize(self):
 
   def _reraise_augmented(self, exn):
     if getattr(exn, '_tagged_with_step', False) or not self.step_name:
-      raise
+      raise exn

Review comment:
       lgtm

##########
File path: sdks/python/apache_beam/runners/portability/portable_runner.py
##########
@@ -628,12 +628,10 @@ def _cleanup(self, on_exit=False):
           '  with Pipeline() as p:\n'
           '    p.apply(..)\n'
           'This ensures that the pipeline finishes before this program exits.')
-    has_exception = None
     for callback in self._cleanup_callbacks:
       try:
         callback()
-      except Exception:
-        has_exception = True
-    self._cleanup_callbacks = ()
-    if has_exception:
-      raise
+      except Exception as e:
+        raise e
+      finally:
+        self._cleanup_callbacks = ()

Review comment:
       this code has slightly different behavior, right? The new code may not call all of the cleanup callbacks. If one of them errors out before the end, then the final callbacks will not be processed, right?
   
   Maybe you can store all exceptions, and raise a RuntimeException with information about all of them?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org