What are the differences between asyncio
and cothread
?
-There are two concurrency frameworks that pythonSoftIOC supports, asyncio
and
+
What are the differences between asyncio
and cothread
?
+There are two concurrency frameworks that pythonSoftIOC supports, asyncio
and
cothread
. This page details the differences between them and reasons why you
should use one over the other
The Similarities
The main difference between the libraries is how a coroutine yields control.
-
-
asyncio
uses anasync def
which will yield control when theyawait
. +asyncio
uses anasync def
which will yield control when theyawait
. Only anasync def
canawait
anotherasync def
, so functions that yield control are explicitly marked as such by the presence of theasync
keyword.
@@ -171,17 +171,17 @@ If you run python2.7 then you need to use
cothread
asasyncio
is python3 +If you run python2.7 then you need to use
cothread
asasyncio
is python3 only
-If you run on Windows then you need
asyncio
ascothread
doesn’t work on +If you run on Windows then you need
asyncio
ascothread
doesn’t work on Windows
-If you need to integrate with a library that uses
asyncio
like one from -aio-libs then useasyncio
+If you need to integrate with a library that uses
asyncio
like one from +aio-libs then useasyncio
If you need to turn a script using
cothread.catools
into an IOC then usecothread
softioc.asyncio_dispatcher
A dispatcher for
asyncio
based applications instead of the default +softioc.asyncio_dispatcher
A dispatcher for
asyncio
based applications instead of the defaultcothread
onesoftioc.alarm
This module simply contains definitions for severity and alarm values taken @@ -154,7 +154,7 @@
softioc<
- -softioc.__version__: str +softioc.__version__: str
Version number as calculated by https://github.com/dls-controls/versiongit
Top Level IOC Interface:
See also
-
+softioc.asyncio_dispatcher
is a dispatcher forasyncio
applicationssoftioc.asyncio_dispatcher
is a dispatcher forasyncio
applicationscall_exit – If
True
, the IOC will be terminated by calling epicsExit which means thatinteractive_ioc
will not return
@@ -425,13 +425,13 @@ - class softioc.asyncio_dispatcher.AsyncioDispatcher(loop=None)[source] -
A dispatcher for
asyncio
based IOCs, suitable to be passed to +A dispatcher for
asyncio
based IOCs, suitable to be passed tosoftioc.iocInit
. Means that on_update callback functions can be async.If a
loop
is provided it must already be running. Otherwise a new @@ -495,7 +495,7 @@Creating Records: validate function can reject -the update by returning
False
or accept it by returningTrue
. +the update by returningFalse
or accept it by returningTrue
.Note
This function is called asynchronously on a thread determined by @@ -508,16 +508,16 @@
Creating Records: .PROC will have no visible effect. -
This flag defaults to
False
, in which case updates to the record +This flag defaults to
False
, in which case updates to the record which don’t change its value will be discarded. In particular this means that such updates don’t call validate or on_update.blocking
-Only available on OUT records. When set to
True
the record will set the +Only available on OUT records. When set to
-True
the record will set thePACT
field when processing is ongoing. This means thatcaput
and similar tools can correctly wait for processing to complete.This flag defaults to
False
, to retain compatibility with previous +This flag defaults to
False
, to retain compatibility with previous versions.See also
@@ -859,7 +859,7 @@Working with IN records
builder
methods have been used) then the record will be processed by EPICS and the given value will be published to all users.Optionally an explicit timestamp can be set. This is a value in seconds -in the Unix epoch, as returned by
time.time()
. This argument only +in the Unix epoch, as returned bytime.time()
. This argument only has any effect ifTSE = -2
was set when the record was created.Note that when calling
@@ -899,7 +899,7 @@set()
for a waveform record the value is always copied immediately – this avoids accidents with mutable values.Working with OUT recordsset(value, process=True)[source]
diff --git a/master/reference/contributing.html b/master/reference/contributing.html index 1f0ab84f..3b82f2d0 100644 --- a/master/reference/contributing.html +++ b/master/reference/contributing.html @@ -4,7 +4,7 @@ -Updates the value associated with the record. By default this will trigger record processing, and so will cause any associated on_update -and validate methods to be called. If
process
isFalse
+and validate methods to be called. Ifprocess
isFalse
then neither of these methods will be called, but the value will still be updated.Contributing — pythonSoftIOC 4.3.0+7.g07b1168 documentation +Contributing — pythonSoftIOC 4.4.0+1.gdad702c documentation diff --git a/master/search.html b/master/search.html index dd8b342c..fecd10ac 100644 --- a/master/search.html +++ b/master/search.html @@ -3,7 +3,7 @@ -Search — pythonSoftIOC 4.3.0+7.g07b1168 documentation +Search — pythonSoftIOC 4.4.0+1.gdad702c documentation diff --git a/master/tutorials/creating-an-ioc.html b/master/tutorials/creating-an-ioc.html index 0078d1f9..282f3ed9 100644 --- a/master/tutorials/creating-an-ioc.html +++ b/master/tutorials/creating-an-ioc.html @@ -4,7 +4,7 @@ -Creating an IOC — pythonSoftIOC 4.3.0+7.g07b1168 documentation +Creating an IOC — pythonSoftIOC 4.4.0+1.gdad702c documentation @@ -146,7 +146,7 @@Introduction
Note
-cothread
doesn’t work on Windows or on a Mac M1. You can useasyncio
+cothread
doesn’t work on Windows or on a Mac M1. You can useasyncio
instead by following Use asyncio in an IOCai = builder.aIn('AI', initial_value=5) diff --git a/master/tutorials/installation.html b/master/tutorials/installation.html index 4e8e3f77..5aed2f43 100644 --- a/master/tutorials/installation.html +++ b/master/tutorials/installation.html @@ -4,7 +4,7 @@ -
Installation Tutorial — pythonSoftIOC 4.3.0+7.g07b1168 documentation +Installation Tutorial — pythonSoftIOC 4.4.0+1.gdad702c documentation
The Differences
There are some questions to ask to help you choose which one to use:
-
-
In general, avoid mixing concurrency frameworks if you can. While it is possible
-to mix asyncio
and cothread
, it’s messy and tricky to get right. Better to
+to mix asyncio
and cothread
, it’s messy and tricky to get right. Better to
keep to one if possible.
Calculating PVs from other values
Note
-If using asyncio
then you would use aioca.camonitor
instead of
+
If using asyncio
then you would use aioca.camonitor
instead of
cothread.catools.camonitor
:
from aioca import camonitor
diff --git a/master/genindex.html b/master/genindex.html
index 7e8aa0c6..5d0fc188 100644
--- a/master/genindex.html
+++ b/master/genindex.html
@@ -3,7 +3,7 @@
- Index — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ Index — pythonSoftIOC 4.4.0+1.gdad702c documentation
diff --git a/master/how-to/make-publishable-ioc.html b/master/how-to/make-publishable-ioc.html
index 25381c2a..f44a0cd7 100644
--- a/master/how-to/make-publishable-ioc.html
+++ b/master/how-to/make-publishable-ioc.html
@@ -4,7 +4,7 @@
- Create a Publishable IOC — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ Create a Publishable IOC — pythonSoftIOC 4.4.0+1.gdad702c documentation
diff --git a/master/how-to/read-data-from-ioc.html b/master/how-to/read-data-from-ioc.html
index ef47b19d..769e2370 100644
--- a/master/how-to/read-data-from-ioc.html
+++ b/master/how-to/read-data-from-ioc.html
@@ -4,7 +4,7 @@
- Read data from an IOC — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ Read data from an IOC — pythonSoftIOC 4.4.0+1.gdad702c documentation
@@ -100,7 +100,7 @@
Read data from an IOC
This guide explains how to read data from an IOC in a separate Python program.
To start, run the cothread
IOC from Creating an IOC or the
-asyncio
IOC from Use asyncio in an IOC and leave it running at the
+asyncio
IOC from Use asyncio in an IOC and leave it running at the
interactive shell.
Using Channel Access
diff --git a/master/how-to/use-asyncio-in-an-ioc.html b/master/how-to/use-asyncio-in-an-ioc.html
index a227d3ba..51142136 100644
--- a/master/how-to/use-asyncio-in-an-ioc.html
+++ b/master/how-to/use-asyncio-in-an-ioc.html
@@ -4,7 +4,7 @@
- Use asyncio in an IOC — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ Use asyncio in an IOC — pythonSoftIOC 4.4.0+1.gdad702c documentation
@@ -97,9 +97,9 @@
-Use asyncio
in an IOC
+Use asyncio
in an IOC
Creating an IOC shows how to create a pythonSoftIOC using the
-cothread
library. This page shows how to create one using asyncio
+cothread
library. This page shows how to create one using asyncio
See also
What are the differences between asyncio and cothread? for the differences and why
@@ -139,7 +139,7 @@
Example IOCdispatcher is created and passed to iocInit()
. This is what
-allows the use of asyncio
functions in this IOC. It contains a new event loop to handle
+allows the use of asyncio
functions in this IOC. It contains a new event loop to handle
this.
The async update
function will increment the value of ai
once per second,
sleeping that coroutine between updates.
diff --git a/master/how-to/use-soft-records.html b/master/how-to/use-soft-records.html
index e09afb91..91835f8a 100644
--- a/master/how-to/use-soft-records.html
+++ b/master/how-to/use-soft-records.html
@@ -4,7 +4,7 @@
-
Use soft records in an IOC — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ Use soft records in an IOC — pythonSoftIOC 4.4.0+1.gdad702c documentation
diff --git a/master/index.html b/master/index.html
index bfd03115..28332af4 100644
--- a/master/index.html
+++ b/master/index.html
@@ -4,7 +4,7 @@
- pythonSoftIOC — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ pythonSoftIOC — pythonSoftIOC 4.4.0+1.gdad702c documentation
diff --git a/master/py-modindex.html b/master/py-modindex.html
index 5f400877..db2121ca 100644
--- a/master/py-modindex.html
+++ b/master/py-modindex.html
@@ -3,7 +3,7 @@
- Python Module Index — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ Python Module Index — pythonSoftIOC 4.4.0+1.gdad702c documentation
diff --git a/master/reference/api.html b/master/reference/api.html
index 4afa568e..91bb0dbd 100644
--- a/master/reference/api.html
+++ b/master/reference/api.html
@@ -4,7 +4,7 @@
- API — pythonSoftIOC 4.3.0+7.g07b1168 documentation
+ API — pythonSoftIOC 4.4.0+1.gdad702c documentation
@@ -124,7 +124,7 @@ softioc<
interactive EPICS commands are wrapped and can be made available through the
interpreter by invoking the interpreter through this module.
-
@@ -213,7 +213,7 @@ Top Level IOC Interface: True
, the IOC will be terminated by calling epicsExit
+
Top Level IOC Interface:
Asyncio Dispatcher: softioc.asyncio_dispatcher
-If your application uses asyncio
then this module gives an alternative
+
If your application uses asyncio
then this module gives an alternative
dispatcher for caput requests.
asyncio
then you would use aioca.camonitor
instead of
+asyncio
then you would use aioca.camonitor
instead of
cothread.catools.camonitor
:from aioca import camonitor
Read data from an IOC
This guide explains how to read data from an IOC in a separate Python program.
To start, run the cothread
IOC from Creating an IOC or the
-asyncio
IOC from Use asyncio in an IOC and leave it running at the
+asyncio
IOC from Use asyncio in an IOC and leave it running at the
interactive shell.
Using Channel Access
diff --git a/master/how-to/use-asyncio-in-an-ioc.html b/master/how-to/use-asyncio-in-an-ioc.html index a227d3ba..51142136 100644 --- a/master/how-to/use-asyncio-in-an-ioc.html +++ b/master/how-to/use-asyncio-in-an-ioc.html @@ -4,7 +4,7 @@ -Use asyncio
in an IOC
+Use asyncio
in an IOC
Creating an IOC shows how to create a pythonSoftIOC using the
-cothread
library. This page shows how to create one using asyncio
cothread
library. This page shows how to create one using asyncio
See also
What are the differences between asyncio and cothread? for the differences and why @@ -139,7 +139,7 @@
Example IOCdispatcher is created and passed to iocInit()
. This is what
-allows the use of asyncio
functions in this IOC. It contains a new event loop to handle
+allows the use of asyncio
functions in this IOC. It contains a new event loop to handle
this.
The async update
function will increment the value of ai
once per second,
sleeping that coroutine between updates.
diff --git a/master/how-to/use-soft-records.html b/master/how-to/use-soft-records.html
index e09afb91..91835f8a 100644
--- a/master/how-to/use-soft-records.html
+++ b/master/how-to/use-soft-records.html
@@ -4,7 +4,7 @@
-
softioc<
interactive EPICS commands are wrapped and can be made available through the
interpreter by invoking the interpreter through this module.
-
Top Level IOC Interface: True
, the IOC will be terminated by calling epicsExit
+
Top Level IOC Interface:
Asyncio Dispatcher: softioc.asyncio_dispatcher
-If your application uses asyncio
then this module gives an alternative
+
If your application uses asyncio
then this module gives an alternative
dispatcher for caput requests.
Asyncio Dispatcher: softioc.asyncio_dispatcher
-If your application uses asyncio
then this module gives an alternative
+
If your application uses asyncio
then this module gives an alternative
dispatcher for caput requests.