Skip to content

Commit 0591f51

Browse files
Add documentation of blocking and SetBlocking
Renamed the function to conform to naming convention. Added CHANGELOG entry.
1 parent bb322f0 commit 0591f51

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Versioning <https://semver.org/spec/v2.0.0.html>`_.
1010
Unreleased_
1111
-----------
1212

13+
Added:
14+
15+
- `Caput with callback <../../pull/98>`_
16+
1317
Fixed:
1418

1519
- `Passing a custom asyncio event loop into the AsyncioDispatcher causes methods to never run <../../pull/96>`_

docs/reference/api.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ Test Facilities`_ documentation for more details of each function.
228228
which don't change its value will be discarded. In particular this means
229229
that such updates don't call `validate` or `on_update`.
230230

231+
.. _blocking:
232+
233+
`blocking`
234+
~~~~~~~~~~
235+
236+
Only available on OUT records. When set to `True` the record will set the
237+
``PACT`` field when processing is ongoing. This means that ``caput`` and
238+
similar tools can correctly wait for processing to complete.
239+
240+
This flag defaults to `False`, to retain compatibility with previous
241+
versions.
242+
243+
.. seealso::
244+
`SetBlocking` for configuring a global default blocking value
245+
246+
247+
231248
For all of these functions any EPICS database field can be assigned a value by
232249
passing it as a keyword argument for the corresponding field name (in upper
233250
case) or by assigning to the corresponding field of the returned record object.
@@ -358,6 +375,17 @@ record creation function.
358375
prevent the accidential creation of records with the currently set device
359376
name.
360377

378+
.. function:: SetBlocking(blocking)
379+
380+
This can be used to globally set the default `blocking` flag, which will
381+
apply to all records created after this point. This allows blocking to be
382+
easily set/unset when creating groups of records.
383+
384+
This does not change the blocking value for any already created records.
385+
386+
.. seealso::
387+
`blocking` for description of the flag
388+
361389

362390
The following helper functions are useful when constructing links between
363391
records.

softioc/builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from . import device, pythonSoftIoc # noqa
1111
# Re-export this so users only have to import the builder
12-
from .device import set_blocking # noqa
12+
from .device import SetBlocking # noqa
1313

1414
PythonDevice = pythonSoftIoc.PythonDevice()
1515

@@ -305,5 +305,5 @@ def UnsetDevice():
305305
'LoadDatabase',
306306
'SetDeviceName', 'UnsetDevice',
307307
# Device support functions
308-
'set_blocking'
308+
'SetBlocking'
309309
]

softioc/device.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
# Default False to maintain behaviour from previous versions.
2828
blocking = False
2929

30-
# TODO: Docs and Tests for the Blocking feature
31-
def set_blocking(val):
30+
def SetBlocking(val):
3231
global blocking
3332
blocking = val
3433

tests/test_records.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717

1818
from softioc import asyncio_dispatcher, builder, softioc
19-
from softioc.device import set_blocking
19+
from softioc.device import SetBlocking
2020

2121
# Test file for miscellaneous tests related to records
2222

@@ -185,6 +185,7 @@ def test_pini_always_on():
185185
def validate_fixture_names(params):
186186
"""Provide nice names for the out_records fixture in TestValidate class"""
187187
return params[0].__name__
188+
188189
class TestValidate:
189190
"""Tests related to the validate callback"""
190191

@@ -524,11 +525,11 @@ def test_blocking_creates_attributes(self):
524525

525526
def test_blocking_global_flag_creates_attributes(self):
526527
"""Test that the global blocking flag creates the expected attributes"""
527-
set_blocking(True)
528+
SetBlocking(True)
528529
bo1 = builder.boolOut("OUTREC1")
529530
self.check_record_blocking_attributes(bo1)
530531

531-
set_blocking(False)
532+
SetBlocking(False)
532533
bo2 = builder.boolOut("OUTREC2")
533534
assert bo2._blocking is False
534535

@@ -576,6 +577,7 @@ async def blocking_update_func(new_val):
576577

577578
log("CHILD: Received exit command, child exiting")
578579

580+
@requires_cothread
579581
def test_blocking_single_thread_multiple_calls(self):
580582
"""Test that a blocking record correctly causes multiple caputs from
581583
a single thread to wait for the expected time"""

0 commit comments

Comments
 (0)