|
45 | 45 | from ..._exceptions import BoltError |
46 | 46 | from ..._routing import RoutingTable |
47 | 47 | from ...api import ( |
| 48 | + check_access_mode, |
48 | 49 | READ_ACCESS, |
49 | | - WRITE_ACCESS, |
50 | 50 | ) |
51 | 51 | from ...exceptions import ( |
52 | 52 | ClientError, |
@@ -669,6 +669,7 @@ async def acquire( |
669 | 669 | ): |
670 | 670 | # The access_mode and database is not needed for a direct connection, |
671 | 671 | # it's just there for consistency. |
| 672 | + access_mode = check_access_mode(access_mode) |
672 | 673 | log.debug( |
673 | 674 | "[#0000] _: <POOL> acquire direct connection, " |
674 | 675 | "access_mode=%r, database=%r", |
@@ -1063,8 +1064,6 @@ async def ensure_routing_table_is_fresh( |
1063 | 1064 |
|
1064 | 1065 | :returns: `True` if an update was required, `False` otherwise. |
1065 | 1066 | """ |
1066 | | - from ...api import READ_ACCESS |
1067 | | - |
1068 | 1067 | async with self.refresh_lock: |
1069 | 1068 | for database_ in list(self.routing_tables.keys()): |
1070 | 1069 | # Remove unused databases in the routing table |
@@ -1111,8 +1110,6 @@ async def wrapped_database_callback(database: str | None) -> None: |
1111 | 1110 |
|
1112 | 1111 | async def _select_address(self, *, access_mode, database): |
1113 | 1112 | """Select the address with the fewest in-use connections.""" |
1114 | | - from ...api import READ_ACCESS |
1115 | | - |
1116 | 1113 | async with self.refresh_lock: |
1117 | 1114 | routing_table = self.routing_tables.get(database) |
1118 | 1115 | if routing_table: |
@@ -1149,19 +1146,13 @@ async def acquire( |
1149 | 1146 | unprepared=False, |
1150 | 1147 | database_callback=None, |
1151 | 1148 | ): |
1152 | | - if access_mode not in {WRITE_ACCESS, READ_ACCESS}: |
1153 | | - # TODO: 6.0 - change this to be a ValueError |
1154 | | - raise ClientError(f"Non valid 'access_mode'; {access_mode}") |
| 1149 | + access_mode = check_access_mode(access_mode) |
1155 | 1150 | if not timeout: |
1156 | 1151 | # TODO: 6.0 - change this to be a ValueError |
1157 | 1152 | raise ClientError( |
1158 | 1153 | f"'timeout' must be a float larger than 0; {timeout}" |
1159 | 1154 | ) |
1160 | 1155 |
|
1161 | | - from ...api import check_access_mode |
1162 | | - |
1163 | | - access_mode = check_access_mode(access_mode) |
1164 | | - |
1165 | 1156 | target_database = database.name |
1166 | 1157 |
|
1167 | 1158 | async def wrapped_database_callback(new_database): |
|
0 commit comments