File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 1
1
2
2
class CothreadDispatcher :
3
- def __init__ (self ):
3
+ def __init__ (self , dispatcher = None ):
4
4
"""A dispatcher for `cothread` based IOCs, suitable to be passed to
5
- `softioc.iocInit`. """
6
- # Import here to ensure we don't instantiate any of cothread's global
7
- # state unless we have to
8
- import cothread
9
- # Create our own cothread callback queue so that our callbacks
10
- # processing doesn't interfere with other callback processing.
11
- self .__dispatcher = cothread .cothread ._Callback ()
5
+ `softioc.iocInit`. By default scheduled tasks are run on a dedicated
6
+ cothread callback thread, but an alternative dispatcher can optionally
7
+ be specified here. Realistically the only sensible alternative is to
8
+ pass `cothread.Spawn`, which would create a separate cothread for each
9
+ dispatched callback.
10
+ """
11
+
12
+ if dispatcher is None :
13
+ # Import here to ensure we don't instantiate any of cothread's
14
+ # global state unless we have to
15
+ import cothread
16
+ # Create our own cothread callback queue so that our callbacks
17
+ # processing doesn't interfere with other callback processing.
18
+ self .__dispatcher = cothread .cothread ._Callback ()
19
+ else :
20
+ self .__dispatcher = dispatcher
12
21
13
22
def __call__ (
14
23
self ,
You can’t perform that action at this time.
0 commit comments