Updated code quality ignored bare except warnings changes in proofofwork.py

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-08-25 20:36:00 +05:30
parent fb3de9936c
commit a3953017b6
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A

View File

@ -82,7 +82,7 @@ def _set_idle():
pid = win32api.GetCurrentProcessId() pid = win32api.GetCurrentProcessId()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid) handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS) win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS)
except: except: # noqa:E722
# Windows 64-bit # Windows 64-bit
pass pass
@ -116,11 +116,11 @@ def _doFastPoW(target, initialHash):
from multiprocessing import Pool, cpu_count from multiprocessing import Pool, cpu_count
try: try:
pool_size = cpu_count() pool_size = cpu_count()
except: except: # noqa:E722
pool_size = 4 pool_size = 4
try: try:
maxCores = BMConfigParser().getint('bitmessagesettings', 'maxcores') maxCores = BMConfigParser().getint('bitmessagesettings', 'maxcores')
except: except: # noqa:E722
maxCores = 99999 maxCores = 99999
if pool_size > maxCores: if pool_size > maxCores:
pool_size = maxCores pool_size = maxCores
@ -135,7 +135,7 @@ def _doFastPoW(target, initialHash):
try: try:
pool.terminate() pool.terminate()
pool.join() pool.join()
except: except: # noqa:E722
pass pass
raise StopIteration("Interrupted") raise StopIteration("Interrupted")
for i in range(pool_size): for i in range(pool_size):
@ -281,7 +281,7 @@ def buildCPoW():
notifyBuild(True) notifyBuild(True)
else: else:
notifyBuild(True) notifyBuild(True)
except: except: # noqa:E722
notifyBuild(True) notifyBuild(True)
@ -296,14 +296,14 @@ def run(target, initialHash):
return _doGPUPoW(target, initialHash) return _doGPUPoW(target, initialHash)
except StopIteration: except StopIteration:
raise raise
except: except: # noqa:E722
pass # fallback pass # fallback
if bmpow: if bmpow:
try: try:
return _doCPoW(target, initialHash) return _doCPoW(target, initialHash)
except StopIteration: except StopIteration:
raise raise
except: except: # noqa:E722
pass # fallback pass # fallback
if paths.frozen == "macosx_app" or not paths.frozen: if paths.frozen == "macosx_app" or not paths.frozen:
# on my (Peter Surda) Windows 10, Windows Defender # on my (Peter Surda) Windows 10, Windows Defender
@ -315,13 +315,13 @@ def run(target, initialHash):
except StopIteration: except StopIteration:
logger.error("Fast PoW got StopIteration") logger.error("Fast PoW got StopIteration")
raise raise
except: except: # noqa:E722
logger.error("Fast PoW got exception:", exc_info=True) logger.error("Fast PoW got exception:", exc_info=True)
try: try:
return _doSafePoW(target, initialHash) return _doSafePoW(target, initialHash)
except StopIteration: except StopIteration:
raise raise
except: except: # noqa:E722
pass # fallback pass # fallback
@ -378,7 +378,7 @@ def init():
))[0]) ))[0])
except (OSError, IndexError): except (OSError, IndexError):
bso = None bso = None
except: except: # noqa:E722
bso = None bso = None
else: else:
logger.info("Loaded C PoW DLL %s", bitmsglib) logger.info("Loaded C PoW DLL %s", bitmsglib)
@ -386,7 +386,7 @@ def init():
try: try:
bmpow = bso.BitmessagePOW bmpow = bso.BitmessagePOW
bmpow.restype = ctypes.c_ulonglong bmpow.restype = ctypes.c_ulonglong
except: except: # noqa:E722
bmpow = None bmpow = None
else: else:
bmpow = None bmpow = None