diff --git a/sdks/python/apache_beam/yaml/yaml_provider.py b/sdks/python/apache_beam/yaml/yaml_provider.py index 133a5fe5b714..fb917aef4325 100755 --- a/sdks/python/apache_beam/yaml/yaml_provider.py +++ b/sdks/python/apache_beam/yaml/yaml_provider.py @@ -1184,10 +1184,10 @@ def _create_venv_from_scratch( subprocess.run([venv_pip, 'install'] + packages, check=True) with open(venv + '-requirements.txt', 'w') as fout: fout.write('\n'.join(packages)) - except: # pylint: disable=bare-except + except Exception as e: + logging.warning("Failed to create venv %s from scratch: %s", venv, e, exc_info=True) if os.path.exists(venv): shutil.rmtree(venv, ignore_errors=True) - raise return venv @classmethod @@ -1204,10 +1204,10 @@ def _create_venv_from_clone( subprocess.run([venv_pip, 'install'] + packages, check=True) with open(venv + '-requirements.txt', 'w') as fout: fout.write('\n'.join(packages)) - except: # pylint: disable=bare-except + except Exception as e: + logging.warning("Failed to create venv %s from clone: %s", venv, e, exc_info=True) if os.path.exists(venv): shutil.rmtree(venv, ignore_errors=True) - raise return venv @classmethod