From f159bd4a78abbce00bd97cb2706a8e3b49d97ead Mon Sep 17 00:00:00 2001 From: visi Date: Sat, 26 Dec 2020 09:04:41 -0500 Subject: [PATCH] Added cell.isCellActive() API --- synapse/lib/cell.py | 9 +++++++++ synapse/tests/test_lib_cell.py | 1 + 2 files changed, 10 insertions(+) diff --git a/synapse/lib/cell.py b/synapse/lib/cell.py index 9d4278d7be..d6a6209836 100644 --- a/synapse/lib/cell.py +++ b/synapse/lib/cell.py @@ -147,6 +147,12 @@ def getCellType(self): def getCellIden(self): return self.cell.getCellIden() + async def isCellActive(self): + ''' + Returns True if the cell is an active/leader cell. + ''' + return await self.cell.isCellActive() + @adminapi() def getNexsIndx(self): return self.cell.getNexsIndx() @@ -983,6 +989,9 @@ async def _killActiveCoro(self, cdef): task.cancel() await asyncio.sleep(0) + async def isCellActive(self): + return self.isactive + async def setCellActive(self, active): self.isactive = active diff --git a/synapse/tests/test_lib_cell.py b/synapse/tests/test_lib_cell.py index 3d49c31695..2b5e41821e 100644 --- a/synapse/tests/test_lib_cell.py +++ b/synapse/tests/test_lib_cell.py @@ -241,6 +241,7 @@ async def test_cell_unix_sock(self): async with core.getLocalProxy() as prox: user = await prox.getCellUser() self.eq('root', user.get('name')) + self.true(await prox.isCellActive()) # Explicit use of the unix:// handler async with self.getTestCore() as core: