37 alternative concurrency handling#38
Conversation
…n/p4pillon into 28-monkey-patch-servercli
…rednt-handler-initialisation
|
This example may make it more obvious than the new tests what this allows: from p4p.server import Server
from p4pillon.asyncio.sharednt import SharedNT as AsyncioSharedNT
from p4pillon.nt import NTScalar
from p4pillon.thread.sharednt import SharedNT as ThreadSharedNT
a = AsyncioSharedNT(nt=NTScalar("d"), initial=5.5)
b = ThreadSharedNT(nt=NTScalar("d"), initial=9.9)
Server.forever(
providers=[
{
"demo:a": a,
"demo:b": b,
}
]
)You'll need to do your own pvgets |
|
A little more thought... I think I can see how to do some (all?) of this with straightforward subclassing rather than weird monkey-patching. |
|
The latest commit shows an example for I've also begun adding |
|
These changes weren't as wide-ranging as I expected. And, in fact, even the change to However, this does now include adding ABC (abstract base class) in a number of places. This means that, for example. only |
This is a messy PR because it includes fixes for the problems in the previous PR merged into main. However, once those are excluded there are two places to look. Firstly, the file
test/integrations/test_mixed_concurrency.pyshows what these changes allow. It's not possible to use threading and asyncio in the same program.Then the files in
p4pillon/threadandp4pillon/asynciouse a version of monkey-patching to slightly alter the base files to use the appropriate concurrency model.Many of the remaining changes are then switching from the
p4pillon.concurrencystring to the new method.