Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ff41291

Browse files
authoredAug 11, 2023
fix: subscribe methods shouldn't end with () and topology timeout (#70)
1 parent 974d5f0 commit ff41291

7 files changed

+36
-29
lines changed
 

‎aws_wrapper/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ class AwsWrapperError(Error):
2121

2222
class FailoverError(AwsWrapperError):
2323
__module__ = "aws_wrapper"
24+
25+
26+
class QueryTimeoutError(AwsWrapperError):
27+
__module__ = "aws_wrapper"

‎aws_wrapper/exceptions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
from typing import TYPE_CHECKING
1818

19+
from aws_wrapper.errors import QueryTimeoutError
20+
1921
if TYPE_CHECKING:
2022
from aws_wrapper.dialect import Dialect
2123

@@ -55,7 +57,8 @@ class PgExceptionHandler(ExceptionHandler):
5557
_PAM_AUTHENTICATION_FAILED_MSG = "PAM authentication failed"
5658

5759
def is_network_exception(self, error: Optional[Exception] = None, sql_state: Optional[str] = None) -> bool:
58-
# TODO: verify implementation
60+
if isinstance(error, QueryTimeoutError):
61+
return True
5962

6063
if sql_state:
6164
if sql_state in self._NETWORK_ERRORS:

‎aws_wrapper/generic_target_driver_dialect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ def prepare_connect_info(self, host_info: HostInfo, props: Properties) -> Proper
5959
prop_copy["port"] = str(host_info.port)
6060

6161
PropertiesUtils.remove_wrapper_props(prop_copy)
62-
return props
62+
return prop_copy

‎aws_wrapper/host_list_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from aws_wrapper.plugin_service import PluginService
2929

3030
from aws_wrapper.dialect import Dialect, TopologyAwareDatabaseDialect
31-
from aws_wrapper.errors import AwsWrapperError
31+
from aws_wrapper.errors import AwsWrapperError, QueryTimeoutError
3232
from aws_wrapper.hostinfo import HostAvailability, HostInfo, HostRole
3333
from aws_wrapper.pep249 import Connection, Cursor, Error, ProgrammingError
3434
from aws_wrapper.plugin import Plugin, PluginFactory
@@ -238,7 +238,7 @@ def _get_topology(self, conn: Optional[Connection], force_update: bool = False)
238238
self._suggest_cluster_id(hosts)
239239
return AuroraHostListProvider.FetchTopologyResult(hosts, False)
240240
except Exception as e:
241-
raise AwsWrapperError(Messages.get("AuroraHostListProvider.TopologyTimeout")) from e
241+
raise QueryTimeoutError(Messages.get("AuroraHostListProvider.TopologyTimeout")) from e
242242

243243
if cached_hosts:
244244
return AuroraHostListProvider.FetchTopologyResult(cached_hosts, True)

‎aws_wrapper/mariadb_target_driver_dialect.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class MariaDBTargetDriverDialect(GenericTargetDriverDialect):
2727

2828
_dialect_code: str = TargetDriverDialectCodes.MARIADB_CONNECTOR_PYTHON
2929
_network_bound_methods: Set[str] = {
30-
"Connection.commit()",
31-
"Connection.rollback()",
32-
"Connection.cursor()",
33-
"Cursor.callproc()",
34-
"Cursor.execute()",
35-
"Cursor.fetchone()",
36-
"Cursor.fetchmany()",
37-
"Cursor.fetchall()",
38-
"Cursor.nextset()",
30+
"Connection.commit",
31+
"Connection.rollback",
32+
"Connection.cursor",
33+
"Cursor.callproc",
34+
"Cursor.execute",
35+
"Cursor.fetchone",
36+
"Cursor.fetchmany",
37+
"Cursor.fetchall",
38+
"Cursor.nextset",
3939
}
4040

4141
def is_dialect(self, conn: Callable) -> bool:

‎aws_wrapper/mysql_target_driver_dialect.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class MySQLTargetDriverDialect(GenericTargetDriverDialect):
2727

2828
_dialect_code: str = TargetDriverDialectCodes.MYSQL_CONNECTOR_PYTHON
2929
_network_bound_methods: Set[str] = {
30-
"Connection.commit()",
31-
"Connection.rollback()",
32-
"Connection.cursor()",
33-
"Cursor.close()",
34-
"Cursor.execute()",
35-
"Cursor.fetchone()",
36-
"Cursor.fetchmany()",
37-
"Cursor.fetchall()",
30+
"Connection.commit",
31+
"Connection.rollback",
32+
"Connection.cursor",
33+
"Cursor.close",
34+
"Cursor.execute",
35+
"Cursor.fetchone",
36+
"Cursor.fetchmany",
37+
"Cursor.fetchall",
3838
}
3939

4040
def is_dialect(self, conn: Callable) -> bool:

‎aws_wrapper/pg_target_driver_dialect.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class PgTargetDriverDialect(GenericTargetDriverDialect):
2626

2727
_dialect_code: str = TargetDriverDialectCodes.PSYCOPG
2828
_network_bound_methods: Set[str] = {
29-
"Connection.commit()",
30-
"Connection.rollback()",
31-
"Connection.cursor()",
32-
"Cursor.callproc()",
33-
"Cursor.execute()",
34-
"Cursor.fetchone()",
35-
"Cursor.fetchmany()",
36-
"Cursor.fetchall()",
29+
"Connection.commit",
30+
"Connection.rollback",
31+
"Connection.cursor",
32+
"Cursor.callproc",
33+
"Cursor.execute",
34+
"Cursor.fetchone",
35+
"Cursor.fetchmany",
36+
"Cursor.fetchall",
3737
}
3838

3939
def is_dialect(self, conn: Callable) -> bool:

0 commit comments

Comments
 (0)
Please sign in to comment.