diff --git a/pxii_bec/devices/smargopolo_smargon.py b/pxii_bec/devices/smargopolo_smargon.py index 9af7bdf..899c8a1 100644 --- a/pxii_bec/devices/smargopolo_smargon.py +++ b/pxii_bec/devices/smargopolo_smargon.py @@ -6,7 +6,7 @@ from ophyd import Component as Cpt from ophyd import OphydObject from ophyd_devices import PSIDeviceBase from ophyd_devices.utils.socket import SocketSignal -from requests import Response, get, put +from requests import Response, Session _TIMESTAMP_ID = "__timestamp" _POLL_INTERVAL_SLOW = 0.1 @@ -55,6 +55,7 @@ class SmargonController(OphydObject): """Controller to consolidate polling loops and other REST calls for the smargon""" def __init__(self, *, prefix, **kwargs): + self._session = Session() self._prefix = prefix self._readback_endpoint = "/readbackSCS" self._target_endpoint = "/targetSCS" @@ -105,13 +106,13 @@ class SmargonController(OphydObject): self._signal_registry.add(axis_id) def _rest_get(self, endpoint): - resp = get(self._prefix + endpoint) + resp = self._session.get(self._prefix + endpoint) if not resp.ok: raise HttpRestError(resp) return resp.json() def _rest_put(self, val: dict[str, float]): - resp = put(self._prefix + self._target_endpoint, params=val) + resp = self._session.put(self._prefix + self._target_endpoint, params=val) if not resp.ok: raise HttpRestError(resp, value=val) @@ -140,7 +141,6 @@ class SmargonController(OphydObject): class Smargon(PSIDeviceBase): - x = Cpt(SmargonSignal, axis_identifier="SHX", tolerance=0.01) y = Cpt(SmargonSignal, axis_identifier="SHY", tolerance=0.01) z = Cpt(SmargonSignal, axis_identifier="SHZ", tolerance=0.01)