Skip to content

Commit 1f0d095

Browse files
committed
FastCS 0.12.0
1 parent 3fd7098 commit 1f0d095

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

examples/epics_ca.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
parser = argparse.ArgumentParser(description="Demo PVA ioc")
1919
parser.add_argument("-i", "--ip", type=str, default="127.0.0.1", help="IP to connect to")
20-
parser.add_argument("-p", "--port", type=int, help="Port to connect to")
20+
parser.add_argument("-p", "--port", type=int, help="Port to connect to", required=True)
2121
args = parser.parse_args()
2222

2323
configure_logging(level=LogLevel.DEBUG)

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ classifiers = [
2727
]
2828

2929
dependencies = [
30-
# Remove pin when new release made
31-
"fastcs @ git+https://github.com/DiamondLightSource/FastCS",
30+
"fastcs==0.12.0",
3231
"orjson",
3332
]
3433

@@ -44,7 +43,7 @@ doc = [
4443
]
4544
lint = [
4645
"pyright==1.1.408",
47-
"ruff==0.15.5",
46+
"ruff==0.15.6",
4847
]
4948
test = [
5049
"lewis",

src/fastcs_secop/_controllers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,15 @@ def __init__(self, settings: IPConnectionSettings, quirks: SecopQuirks | None =
268268

269269
async def connect(self) -> None:
270270
"""Connect to the SECoP node."""
271-
await self._connection.connect(self._ip_settings)
271+
try:
272+
await self._connection.connect(self._ip_settings)
273+
self._connected = True
274+
except Exception as e:
275+
logger.error("Failed to (re-)connect to SECoP node due to %s", e)
276+
self._connected = False
277+
278+
async def reconnect(self) -> None:
279+
await self.connect()
272280

273281
async def deactivate(self) -> None:
274282
"""Turn off asynchronous SECoP communication.

tests/test_against_emulator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def emulator():
3131
"stream: {bind_address: 127.0.0.1, port: 57677}",
3232
],
3333
cwd=os.path.dirname(__file__),
34+
stdout=sys.stdout,
35+
stderr=sys.stderr,
3436
)
3537
try:
3638
yield

tests/test_controller.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ def controller():
2323
)
2424

2525

26+
async def test_connect_fails(controller):
27+
with patch.object(controller._connection, "send_query", AsyncMock(side_effect=IOError)):
28+
await controller.connect()
29+
assert not controller._connected
30+
31+
32+
async def test_reconnect_fails(controller):
33+
with patch.object(controller._connection, "send_query", AsyncMock(side_effect=IOError)):
34+
await controller.reconnect()
35+
assert not controller._connected
36+
37+
2638
async def test_ping_happy_path(controller):
2739
with patch.object(controller._connection, "send_query", AsyncMock(return_value="pong")):
2840
controller.connect = AsyncMock()

0 commit comments

Comments
 (0)