Skip to content

Commit

Permalink
Eliminate bare exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Feb 8, 2018
1 parent 436f98e commit 52aa13c
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pulsar/cache/persistence.py
Expand Up @@ -31,7 +31,7 @@ def _with_lock(self, func, suppress_exception=True):
with self._lock():
try:
return func()
except:
except Exception:
traceback.print_exc()
if not suppress_exception:
raise
2 changes: 1 addition & 1 deletion pulsar/client/amqp_exchange.py
Expand Up @@ -231,7 +231,7 @@ def ack_manager(self):
unack_uuid, resubmit_queue)
self.publish(resubmit_queue, payload)
self.publish_uuid_store.set_time(unack_uuid)
except:
except Exception:
log.exception("Problem with acknowledgement manager, leaving ack_manager method in problematic state!")
raise
log.debug('Acknowledgedment manager thread exiting')
Expand Down
2 changes: 1 addition & 1 deletion pulsar/client/decorators.py
Expand Up @@ -26,7 +26,7 @@ def replacement(*args, **kwargs):
count += 1
try:
return func(*args, **kwargs)
except:
except Exception:
if count >= max_count:
raise
else:
Expand Down
4 changes: 2 additions & 2 deletions pulsar/client/transport/poster.py
Expand Up @@ -31,8 +31,8 @@ def post_file(url, path):
datagen, headers = poster.encode.multipart_encode({"file": open(path, "rb")})
request = Request(url, datagen, headers)
return urlopen(request).read()
except:
log.exception("problem")
except Exception:
log.exception("Problem with poster post of [%s]" % path)
raise


Expand Down
1 change: 1 addition & 0 deletions pulsar/main.py
Expand Up @@ -139,6 +139,7 @@ def _find_default_app_config(*config_dirs):
app_config_path = os.path.join(config_dir, DEFAULT_APP_YAML)
if os.path.exists(app_config_path):
return app_config_path

return None


Expand Down
4 changes: 2 additions & 2 deletions pulsar/managers/base/__init__.py
Expand Up @@ -79,7 +79,7 @@ def clean(self, job_id):
if job_directory.exists():
try:
job_directory.delete()
except:
except Exception:
pass

def system_properties(self):
Expand Down Expand Up @@ -241,7 +241,7 @@ def read_file(self, name, default=None):
try:
job_file = open(path, 'rb')
return job_file.read()
except:
except Exception:
if default is not None:
return default
else:
Expand Down
2 changes: 1 addition & 1 deletion pulsar/managers/queued.py
Expand Up @@ -90,6 +90,6 @@ def run_next(self):
log.exception("Running command but failed to delete - command may rerun on Pulsar boot.")
# _run will not do anything if job has been cancelled.
self._run(job_id, command_line, async=False)
except:
except Exception:
log.warn("Uncaught exception running job with job_id %s" % job_id)
traceback.print_exc()
2 changes: 1 addition & 1 deletion pulsar/managers/unqueued.py
Expand Up @@ -46,7 +46,7 @@ def __get_pid(self, job_id):
pid = self._job_directory(job_id).load_metadata(JOB_FILE_PID)
if pid is not None:
pid = int(pid)
except:
except Exception:
pass
return pid

Expand Down
2 changes: 1 addition & 1 deletion pulsar/managers/util/cli/job/slurm.py
Expand Up @@ -42,7 +42,7 @@ def job_script_kwargs(self, ofile, efile, job_name):
if not k.startswith('-'):
k = argmap[k]
scriptargs[k] = v
except:
except Exception:
log.warning('Unrecognized long argument passed to Slurm CLI plugin: %s' % k)

# Generated template.
Expand Down
2 changes: 1 addition & 1 deletion pulsar/managers/util/cli/job/torque.py
@@ -1,7 +1,7 @@
from logging import getLogger
try:
import xml.etree.cElementTree as et
except:
except ImportError:
import xml.etree.ElementTree as et

try:
Expand Down
2 changes: 1 addition & 1 deletion pulsar/tools/authorization.py
Expand Up @@ -73,7 +73,7 @@ def get_authorization(self, tool_id):
tool = None
try:
tool = self.toolbox.get_tool(tool_id)
except:
except Exception:
pass
return ToolBasedAuthorization(tool)

Expand Down
2 changes: 1 addition & 1 deletion test/persistence_test.py
Expand Up @@ -40,5 +40,5 @@ def test_persistence():
shutil.rmtree(staging_directory)
try:
queue2.shutdown()
except:
except Exception:
pass
2 changes: 1 addition & 1 deletion test/routes_test.py
Expand Up @@ -19,6 +19,6 @@ def test_output_path_security():
raised_exception = False
try:
_output_path(manager, '1', '../moo', 'direct')
except:
except Exception:
raised_exception = True
assert raised_exception
2 changes: 1 addition & 1 deletion test/wsgi_app_test.py
Expand Up @@ -45,7 +45,7 @@ def test_upload(upload_type):
try:
app.get("/jobs/%s/files?name=test_output2&type=output" % job_id)
assert False # Should throw exception
except:
except Exception:
pass

command_line = quote("""python -c "import sys; sys.stdout.write('test_out')" """)
Expand Down

0 comments on commit 52aa13c

Please sign in to comment.