Skip to content

Commit 6523ad0

Browse files
authored
It's liveness, not lifeness (#715)
English do be a hard language sometimes...
1 parent 870a8b5 commit 6523ad0

File tree

10 files changed

+100
-100
lines changed

10 files changed

+100
-100
lines changed

neo4j/_async/io/_pool.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async def _acquire_new(self, address, timeout):
132132
return connection
133133
return None
134134

135-
async def _acquire(self, address, timeout, lifeness_check_timeout):
135+
async def _acquire(self, address, timeout, liveness_check_timeout):
136136
""" Acquire a connection to a given address from the pool.
137137
The address supplied should always be an IP address, not
138138
a host name.
@@ -152,8 +152,8 @@ async def health_check(connection_):
152152
or connection_.defunct()
153153
or connection_.stale()):
154154
return False
155-
if lifeness_check_timeout is not None:
156-
if connection_.is_idle_for(lifeness_check_timeout):
155+
if liveness_check_timeout is not None:
156+
if connection_.is_idle_for(liveness_check_timeout):
157157
try:
158158
await connection_.reset()
159159
except (OSError, ServiceUnavailable, SessionExpired):
@@ -186,15 +186,15 @@ async def health_check(connection_):
186186
@abc.abstractmethod
187187
async def acquire(
188188
self, access_mode=None, timeout=None, database=None, bookmarks=None,
189-
lifeness_check_timeout=None
189+
liveness_check_timeout=None
190190
):
191191
""" Acquire a connection to a server that can satisfy a set of parameters.
192192
193193
:param access_mode:
194194
:param timeout:
195195
:param database:
196196
:param bookmarks:
197-
:param lifeness_check_timeout:
197+
:param liveness_check_timeout:
198198
"""
199199

200200
async def release(self, *connections):
@@ -311,12 +311,12 @@ def __repr__(self):
311311

312312
async def acquire(
313313
self, access_mode=None, timeout=None, database=None, bookmarks=None,
314-
lifeness_check_timeout=None
314+
liveness_check_timeout=None
315315
):
316316
# The access_mode and database is not needed for a direct connection,
317317
# it's just there for consistency.
318318
return await self._acquire(
319-
self.address, timeout, lifeness_check_timeout
319+
self.address, timeout, liveness_check_timeout
320320
)
321321

322322

@@ -666,7 +666,7 @@ async def _select_address(self, *, access_mode, database):
666666

667667
async def acquire(
668668
self, access_mode=None, timeout=None, database=None, bookmarks=None,
669-
lifeness_check_timeout=None
669+
liveness_check_timeout=None
670670
):
671671
if access_mode not in (WRITE_ACCESS, READ_ACCESS):
672672
raise ClientError("Non valid 'access_mode'; {}".format(access_mode))
@@ -697,7 +697,7 @@ async def acquire(
697697
log.debug("[#0000] C: <ACQUIRE ADDRESS> database=%r address=%r", database, address)
698698
# should always be a resolved address
699699
connection = await self._acquire(
700-
address, timeout, lifeness_check_timeout
700+
address, timeout, liveness_check_timeout
701701
)
702702
except (ServiceUnavailable, SessionExpired):
703703
await self.deactivate(address=address)

neo4j/_async/work/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def _result_error(self, _):
135135

136136
async def _get_server_info(self):
137137
assert not self._connection
138-
await self._connect(READ_ACCESS, lifeness_check_timeout=0)
138+
await self._connect(READ_ACCESS, liveness_check_timeout=0)
139139
server_info = self._connection.server_info
140140
await self._disconnect()
141141
return server_info

neo4j/_sync/io/_pool.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _acquire_new(self, address, timeout):
132132
return connection
133133
return None
134134

135-
def _acquire(self, address, timeout, lifeness_check_timeout):
135+
def _acquire(self, address, timeout, liveness_check_timeout):
136136
""" Acquire a connection to a given address from the pool.
137137
The address supplied should always be an IP address, not
138138
a host name.
@@ -152,8 +152,8 @@ def health_check(connection_):
152152
or connection_.defunct()
153153
or connection_.stale()):
154154
return False
155-
if lifeness_check_timeout is not None:
156-
if connection_.is_idle_for(lifeness_check_timeout):
155+
if liveness_check_timeout is not None:
156+
if connection_.is_idle_for(liveness_check_timeout):
157157
try:
158158
connection_.reset()
159159
except (OSError, ServiceUnavailable, SessionExpired):
@@ -186,15 +186,15 @@ def health_check(connection_):
186186
@abc.abstractmethod
187187
def acquire(
188188
self, access_mode=None, timeout=None, database=None, bookmarks=None,
189-
lifeness_check_timeout=None
189+
liveness_check_timeout=None
190190
):
191191
""" Acquire a connection to a server that can satisfy a set of parameters.
192192
193193
:param access_mode:
194194
:param timeout:
195195
:param database:
196196
:param bookmarks:
197-
:param lifeness_check_timeout:
197+
:param liveness_check_timeout:
198198
"""
199199

200200
def release(self, *connections):
@@ -311,12 +311,12 @@ def __repr__(self):
311311

312312
def acquire(
313313
self, access_mode=None, timeout=None, database=None, bookmarks=None,
314-
lifeness_check_timeout=None
314+
liveness_check_timeout=None
315315
):
316316
# The access_mode and database is not needed for a direct connection,
317317
# it's just there for consistency.
318318
return self._acquire(
319-
self.address, timeout, lifeness_check_timeout
319+
self.address, timeout, liveness_check_timeout
320320
)
321321

322322

@@ -666,7 +666,7 @@ def _select_address(self, *, access_mode, database):
666666

667667
def acquire(
668668
self, access_mode=None, timeout=None, database=None, bookmarks=None,
669-
lifeness_check_timeout=None
669+
liveness_check_timeout=None
670670
):
671671
if access_mode not in (WRITE_ACCESS, READ_ACCESS):
672672
raise ClientError("Non valid 'access_mode'; {}".format(access_mode))
@@ -697,7 +697,7 @@ def acquire(
697697
log.debug("[#0000] C: <ACQUIRE ADDRESS> database=%r address=%r", database, address)
698698
# should always be a resolved address
699699
connection = self._acquire(
700-
address, timeout, lifeness_check_timeout
700+
address, timeout, liveness_check_timeout
701701
)
702702
except (ServiceUnavailable, SessionExpired):
703703
self.deactivate(address=address)

neo4j/_sync/work/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _result_error(self, _):
135135

136136
def _get_server_info(self):
137137
assert not self._connection
138-
self._connect(READ_ACCESS, lifeness_check_timeout=0)
138+
self._connect(READ_ACCESS, liveness_check_timeout=0)
139139
server_info = self._connection.server_info
140140
self._disconnect()
141141
return server_info

tests/unit/async_/io/test_direct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ async def opener(addr, timeout):
9090

9191
async def acquire(
9292
self, access_mode=None, timeout=None, database=None, bookmarks=None,
93-
lifeness_check_timeout=None
93+
liveness_check_timeout=None
9494
):
9595
return await self._acquire(self.address, timeout,
96-
lifeness_check_timeout)
96+
liveness_check_timeout)
9797

9898

9999
@mark_async_test

tests/unit/async_/io/test_neo4j_pool.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -258,29 +258,29 @@ async def test_release_does_not_resets_defunct_connections(opener):
258258
cx1.reset.asset_not_called()
259259

260260

261-
@pytest.mark.parametrize("lifeness_timeout", (0, 1, 2))
261+
@pytest.mark.parametrize("liveness_timeout", (0, 1, 2))
262262
@mark_async_test
263-
async def test_acquire_performs_no_lifeness_check_on_fresh_connection(
264-
opener, lifeness_timeout
263+
async def test_acquire_performs_no_liveness_check_on_fresh_connection(
264+
opener, liveness_timeout
265265
):
266266
pool = AsyncNeo4jPool(
267267
opener, PoolConfig(), WorkspaceConfig(), ROUTER_ADDRESS
268268
)
269-
cx1 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
269+
cx1 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
270270
assert cx1.addr == READER_ADDRESS
271271
cx1.reset.asset_not_called()
272272

273273

274-
@pytest.mark.parametrize("lifeness_timeout", (0, 1, 2))
274+
@pytest.mark.parametrize("liveness_timeout", (0, 1, 2))
275275
@mark_async_test
276-
async def test_acquire_performs_lifeness_check_on_existing_connection(
277-
opener, lifeness_timeout
276+
async def test_acquire_performs_liveness_check_on_existing_connection(
277+
opener, liveness_timeout
278278
):
279279
pool = AsyncNeo4jPool(
280280
opener, PoolConfig(), WorkspaceConfig(), ROUTER_ADDRESS
281281
)
282282
# populate the pool with a connection
283-
cx1 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
283+
cx1 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
284284

285285
# make sure we assume the right state
286286
assert cx1.addr == READER_ADDRESS
@@ -293,68 +293,68 @@ async def test_acquire_performs_lifeness_check_on_existing_connection(
293293
await pool.release(cx1)
294294
cx1.reset.assert_not_called()
295295

296-
# then acquire it again and assert the lifeness check was performed
297-
cx2 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
296+
# then acquire it again and assert the liveness check was performed
297+
cx2 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
298298
assert cx1 is cx2
299-
cx1.is_idle_for.assert_called_once_with(lifeness_timeout)
299+
cx1.is_idle_for.assert_called_once_with(liveness_timeout)
300300
cx2.reset.assert_awaited_once()
301301

302302

303-
@pytest.mark.parametrize("lifeness_error",
303+
@pytest.mark.parametrize("liveness_error",
304304
(OSError, ServiceUnavailable, SessionExpired))
305305
@mark_async_test
306-
async def test_acquire_creates_connection_on_failed_lifeness_check(
307-
opener, lifeness_error
306+
async def test_acquire_creates_connection_on_failed_liveness_check(
307+
opener, liveness_error
308308
):
309-
def lifeness_side_effect(*args, **kwargs):
310-
raise lifeness_error("lifeness check failed")
309+
def liveness_side_effect(*args, **kwargs):
310+
raise liveness_error("liveness check failed")
311311

312-
lifeness_timeout = 1
312+
liveness_timeout = 1
313313
pool = AsyncNeo4jPool(
314314
opener, PoolConfig(), WorkspaceConfig(), ROUTER_ADDRESS
315315
)
316316
# populate the pool with a connection
317-
cx1 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
317+
cx1 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
318318

319319
# make sure we assume the right state
320320
assert cx1.addr == READER_ADDRESS
321321
cx1.is_idle_for.assert_not_called()
322322
cx1.reset.assert_not_called()
323323

324324
cx1.is_idle_for.return_value = True
325-
# simulate cx1 failing lifeness check
326-
cx1.reset.side_effect = lifeness_side_effect
325+
# simulate cx1 failing liveness check
326+
cx1.reset.side_effect = liveness_side_effect
327327

328328
# release the connection
329329
await pool.release(cx1)
330330
cx1.reset.assert_not_called()
331331

332-
# then acquire it again and assert the lifeness check was performed
333-
cx2 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
332+
# then acquire it again and assert the liveness check was performed
333+
cx2 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
334334
assert cx1 is not cx2
335335
assert cx1.addr == cx2.addr
336-
cx1.is_idle_for.assert_called_once_with(lifeness_timeout)
336+
cx1.is_idle_for.assert_called_once_with(liveness_timeout)
337337
cx2.reset.assert_not_called()
338338
assert cx1 not in pool.connections[cx1.addr]
339339
assert cx2 in pool.connections[cx1.addr]
340340

341341

342-
@pytest.mark.parametrize("lifeness_error",
342+
@pytest.mark.parametrize("liveness_error",
343343
(OSError, ServiceUnavailable, SessionExpired))
344344
@mark_async_test
345-
async def test_acquire_returns_other_connection_on_failed_lifeness_check(
346-
opener, lifeness_error
345+
async def test_acquire_returns_other_connection_on_failed_liveness_check(
346+
opener, liveness_error
347347
):
348-
def lifeness_side_effect(*args, **kwargs):
349-
raise lifeness_error("lifeness check failed")
348+
def liveness_side_effect(*args, **kwargs):
349+
raise liveness_error("liveness check failed")
350350

351-
lifeness_timeout = 1
351+
liveness_timeout = 1
352352
pool = AsyncNeo4jPool(
353353
opener, PoolConfig(), WorkspaceConfig(), ROUTER_ADDRESS
354354
)
355355
# populate the pool with a connection
356-
cx1 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
357-
cx2 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
356+
cx1 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
357+
cx2 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
358358

359359
# make sure we assume the right state
360360
assert cx1.addr == READER_ADDRESS
@@ -366,21 +366,21 @@ def lifeness_side_effect(*args, **kwargs):
366366

367367
cx1.is_idle_for.return_value = True
368368
cx2.is_idle_for.return_value = True
369-
# simulate cx1 failing lifeness check
370-
cx1.reset.side_effect = lifeness_side_effect
369+
# simulate cx1 failing liveness check
370+
cx1.reset.side_effect = liveness_side_effect
371371

372372
# release the connection
373373
await pool.release(cx1)
374374
await pool.release(cx2)
375375
cx1.reset.assert_not_called()
376376
cx2.reset.assert_not_called()
377377

378-
# then acquire it again and assert the lifeness check was performed
379-
cx3 = await pool._acquire(READER_ADDRESS, 30, lifeness_timeout)
378+
# then acquire it again and assert the liveness check was performed
379+
cx3 = await pool._acquire(READER_ADDRESS, 30, liveness_timeout)
380380
assert cx3 is cx2
381-
cx1.is_idle_for.assert_called_once_with(lifeness_timeout)
381+
cx1.is_idle_for.assert_called_once_with(liveness_timeout)
382382
cx1.reset.assert_awaited_once()
383-
cx3.is_idle_for.assert_called_once_with(lifeness_timeout)
383+
cx3.is_idle_for.assert_called_once_with(liveness_timeout)
384384
cx3.reset.assert_awaited_once()
385385
assert cx1 not in pool.connections[cx1.addr]
386386
assert cx3 in pool.connections[cx1.addr]

tests/unit/async_/test_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async def test_verify_connectivity(uri, mocker):
215215

216216
assert ret is None
217217
pool_mock.acquire.assert_awaited_once()
218-
assert pool_mock.acquire.call_args.kwargs["lifeness_check_timeout"] == 0
218+
assert pool_mock.acquire.call_args.kwargs["liveness_check_timeout"] == 0
219219
pool_mock.release.assert_awaited_once()
220220

221221

tests/unit/sync/io/test_direct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ def opener(addr, timeout):
9090

9191
def acquire(
9292
self, access_mode=None, timeout=None, database=None, bookmarks=None,
93-
lifeness_check_timeout=None
93+
liveness_check_timeout=None
9494
):
9595
return self._acquire(self.address, timeout,
96-
lifeness_check_timeout)
96+
liveness_check_timeout)
9797

9898

9999
@mark_sync_test

0 commit comments

Comments
 (0)