Skip to content

Commit 8bad40f

Browse files
fix: replace 44 bare except clauses with except Exception
1 parent 0f32b2a commit 8bad40f

File tree

26 files changed

+44
-44
lines changed

26 files changed

+44
-44
lines changed

jina/clients/base/grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async def _get_results(
176176
except asyncio.CancelledError as ex:
177177
self.logger.warning(f'process error: {ex!r}')
178178
raise
179-
except:
179+
except Exception:
180180
# Not sure why, adding this line helps in fixing a hanging test
181181
raise
182182

jina/clients/base/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def extract_paths_by_method(spec):
7070
self._endpoints = extract_paths_by_method(openapi_response).get(
7171
'post', []
7272
)
73-
except:
73+
except Exception:
7474
pass
7575

7676
async def _is_flow_ready(self, **kwargs) -> bool:

jina/clients/base/websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _request_handler(
220220
exception_raised = ex
221221
try:
222222
receive_task.cancel()
223-
except:
223+
except Exception:
224224
raise ex
225225
finally:
226226
if iolet.close_code == status.WS_1011_INTERNAL_ERROR:

jina/helper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,11 @@ def get_full_version() -> Optional[Tuple[Dict, Dict]]:
941941

942942
try:
943943
from hubble import __version__ as __hubble_version__
944-
except:
944+
except Exception:
945945
__hubble_version__ = 'not-available'
946946
try:
947947
from jcloud import __version__ as __jcloud_version__
948-
except:
948+
except Exception:
949949
__jcloud_version__ = 'not-available'
950950

951951
from jina import __docarray_version__, __proto_version__, __version__
@@ -1220,7 +1220,7 @@ def _get_ip(url):
12201220
_ip = fp.read().decode().strip()
12211221
return _ip
12221222

1223-
except:
1223+
except Exception:
12241224
pass # intentionally ignored, public ip is not showed
12251225

12261226
ip_server_list = [
@@ -1357,7 +1357,7 @@ def download_mermaid_url(mermaid_url, output) -> None:
13571357
req = Request(mermaid_url, headers={'User-Agent': 'Mozilla/5.0'})
13581358
with open(output, 'wb') as fp:
13591359
fp.write(urlopen(req).read())
1360-
except:
1360+
except Exception:
13611361
from jina.logging.predefined import default_logger
13621362

13631363
default_logger.error(
@@ -1658,7 +1658,7 @@ def _telemetry():
16581658
)
16591659
urllib.request.urlopen(req)
16601660

1661-
except:
1661+
except Exception:
16621662
pass
16631663

16641664
threading.Thread(target=_telemetry, daemon=True).start()

jina/importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def add_modules(*paths):
169169
importlib.import_module(path)
170170
except ModuleNotFoundError:
171171
not_python_module_paths.append(path)
172-
except:
172+
except Exception:
173173
raise
174174
else:
175175
not_python_module_paths.append(path)

jina/jaml/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get_hashable_key(self, key):
3030
"""
3131
try:
3232
hash(key)
33-
except:
33+
except Exception:
3434
if isinstance(key, list):
3535
for i in range(len(key)):
3636
if not isinstance(key[i], collections.abc.Hashable):

jina/orchestrate/deployments/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ def _wait_until_all_ready(self):
10821082

10831083
try:
10841084
_ = asyncio.get_event_loop()
1085-
except:
1085+
except Exception:
10861086
loop = asyncio.new_event_loop()
10871087
asyncio.set_event_loop(loop)
10881088

@@ -1092,7 +1092,7 @@ async def _f():
10921092
running_in_event_loop = False
10931093
try:
10941094
asyncio.get_event_loop().run_until_complete(_f())
1095-
except:
1095+
except Exception:
10961096
running_in_event_loop = True
10971097

10981098
if not running_in_event_loop:
@@ -1193,7 +1193,7 @@ def wait_start_success(self) -> None:
11931193
self.gateway_pod.wait_start_success()
11941194
for shard_id in self.shards:
11951195
self.shards[shard_id].wait_start_success()
1196-
except:
1196+
except Exception:
11971197
self.close()
11981198
raise
11991199

@@ -1217,7 +1217,7 @@ async def async_wait_start_success(self) -> None:
12171217

12181218
await asyncio.gather(*coros)
12191219
self.logger.debug('Deployment started successfully')
1220-
except:
1220+
except Exception:
12211221
self.close()
12221222
raise
12231223

@@ -1288,7 +1288,7 @@ def _parse_devices(value: str, num_devices: int):
12881288
if len(parts) == 1:
12891289
try:
12901290
int(parts[0])
1291-
except:
1291+
except Exception:
12921292
use_uuids = True
12931293
if use_uuids:
12941294
return parts
@@ -1297,7 +1297,7 @@ def _parse_devices(value: str, num_devices: int):
12971297
# try to detect if parts are not numbers
12981298
try:
12991299
int(parts[0])
1300-
except:
1300+
except Exception:
13011301
use_uuids = True
13021302

13031303
if not use_uuids:
@@ -1328,7 +1328,7 @@ def _roundrobin_cuda_device(device_str: Optional[str], replicas: int):
13281328
num_devices = str(subprocess.check_output(['nvidia-smi', '-L'])).count(
13291329
'UUID'
13301330
)
1331-
except:
1331+
except Exception:
13321332
num_devices = int(os.environ.get('CUDA_TOTAL_DEVICES', 0))
13331333
if num_devices == 0:
13341334
return

jina/orchestrate/deployments/config/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_base_executor_version():
9393
return __version__
9494
else:
9595
return 'master'
96-
except:
96+
except Exception:
9797
return 'master'
9898

9999

jina/orchestrate/flow/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ async def _async_wait_all():
19851985
# kick off all deployments wait-ready tasks
19861986
try:
19871987
_ = asyncio.get_event_loop()
1988-
except:
1988+
except Exception:
19891989
loop = asyncio.new_event_loop()
19901990
asyncio.set_event_loop(loop)
19911991

@@ -1995,7 +1995,7 @@ async def _f():
19951995
running_in_event_loop = False
19961996
try:
19971997
asyncio.get_event_loop().run_until_complete(_f())
1998-
except:
1998+
except Exception:
19991999
running_in_event_loop = True
20002000

20012001
wait_ready_threads = []
@@ -2223,7 +2223,7 @@ def plot(
22232223

22242224
display(Image(url=url))
22252225
showed = True
2226-
except:
2226+
except Exception:
22272227
# no need to panic users
22282228
pass
22292229

jina/orchestrate/pods/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def _get_control_address(self):
344344
ctrl_host = client.networks.get(network).attrs['IPAM']['Config'][0][
345345
'Gateway'
346346
]
347-
except:
347+
except Exception:
348348
ctrl_host = __docker_host__
349349
else:
350350
ctrl_host = self.args.host

0 commit comments

Comments
 (0)