Added client error as acceptable exception
All checks were successful
autoBIGS.engine/pipeline/head This commit looks good
All checks were successful
autoBIGS.engine/pipeline/head This commit looks good
This commit is contained in:
parent
1776f5aa51
commit
3cb10a4609
@ -9,7 +9,7 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
from typing import Any, AsyncGenerator, AsyncIterable, Coroutine, Iterable, Mapping, Sequence, Set, Union
|
from typing import Any, AsyncGenerator, AsyncIterable, Coroutine, Iterable, Mapping, Sequence, Set, Union
|
||||||
|
|
||||||
from aiohttp import ClientSession, ClientTimeout, ServerDisconnectedError
|
from aiohttp import ClientOSError, ClientSession, ClientTimeout, ServerDisconnectedError
|
||||||
|
|
||||||
from autobigs.engine.reading import read_fasta
|
from autobigs.engine.reading import read_fasta
|
||||||
from autobigs.engine.structures.alignment import PairwiseAlignment
|
from autobigs.engine.structures.alignment import PairwiseAlignment
|
||||||
@ -100,7 +100,7 @@ class RemoteBIGSdbMLSTProfiler(BIGSdbMLSTProfiler):
|
|||||||
yield result_allele if isinstance(sequence_string, str) else (sequence_string.name, result_allele)
|
yield result_allele if isinstance(sequence_string, str) else (sequence_string.name, result_allele)
|
||||||
else:
|
else:
|
||||||
raise NoBIGSdbMatchesException(self._database_name, self._scheme_id, sequence_string.name if isinstance(sequence_string, NamedString) else None)
|
raise NoBIGSdbMatchesException(self._database_name, self._scheme_id, sequence_string.name if isinstance(sequence_string, NamedString) else None)
|
||||||
except (ConnectionError, ServerDisconnectedError) as e: # Errors we will retry
|
except (ConnectionError, ServerDisconnectedError, ClientOSError) as e: # Errors we will retry
|
||||||
last_error = e
|
last_error = e
|
||||||
success = False
|
success = False
|
||||||
await asyncio.sleep(5) # In case the connection issue is due to rate issues
|
await asyncio.sleep(5) # In case the connection issue is due to rate issues
|
||||||
@ -109,7 +109,7 @@ class RemoteBIGSdbMLSTProfiler(BIGSdbMLSTProfiler):
|
|||||||
if not success and last_error is not None:
|
if not success and last_error is not None:
|
||||||
try:
|
try:
|
||||||
raise last_error
|
raise last_error
|
||||||
except (ConnectionError, ServerDisconnectedError) as e: # Non-fatal errors
|
except (ConnectionError, ServerDisconnectedError, ClientOSError) as e: # Non-fatal errors
|
||||||
yield Allele("error", "error", None)
|
yield Allele("error", "error", None)
|
||||||
|
|
||||||
async def determine_mlst_st(self, alleles: Union[AsyncIterable[Union[Allele, tuple[str, Allele]]], Iterable[Union[Allele, tuple[str, Allele]]]]) -> Union[MLSTProfile, NamedMLSTProfile]:
|
async def determine_mlst_st(self, alleles: Union[AsyncIterable[Union[Allele, tuple[str, Allele]]], Iterable[Union[Allele, tuple[str, Allele]]]]) -> Union[MLSTProfile, NamedMLSTProfile]:
|
||||||
@ -156,7 +156,7 @@ class RemoteBIGSdbMLSTProfiler(BIGSdbMLSTProfiler):
|
|||||||
if len(names_list) > 0:
|
if len(names_list) > 0:
|
||||||
result_mlst_profile = NamedMLSTProfile(str(tuple(names_list)) if len(set(names_list)) > 1 else names_list[0], result_mlst_profile)
|
result_mlst_profile = NamedMLSTProfile(str(tuple(names_list)) if len(set(names_list)) > 1 else names_list[0], result_mlst_profile)
|
||||||
return result_mlst_profile
|
return result_mlst_profile
|
||||||
except (ConnectionError, ServerDisconnectedError) as e:
|
except (ConnectionError, ServerDisconnectedError, ClientOSError) as e:
|
||||||
last_error = e
|
last_error = e
|
||||||
success = False
|
success = False
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
@ -165,7 +165,7 @@ class RemoteBIGSdbMLSTProfiler(BIGSdbMLSTProfiler):
|
|||||||
try:
|
try:
|
||||||
if last_error is not None:
|
if last_error is not None:
|
||||||
raise last_error
|
raise last_error
|
||||||
except (ConnectionError, ServerDisconnectedError) as e:
|
except (ConnectionError, ServerDisconnectedError, ClientOSError) as e:
|
||||||
result_mlst_profile = NamedMLSTProfile((str(tuple(names_list)) if len(set(names_list)) > 1 else names_list[0]) + ":Error", None)
|
result_mlst_profile = NamedMLSTProfile((str(tuple(names_list)) if len(set(names_list)) > 1 else names_list[0]) + ":Error", None)
|
||||||
raise ValueError("Last error was not recorded.")
|
raise ValueError("Last error was not recorded.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user