Open Synthetica9 opened 10 months ago
Indeed Server.forever()
is not async
, and is in p4p.server
instead of p4p.server.asyncio
.
In the short term you could instead do something like:
done = asyncio.Event()
# install signal handler to call done.set()
with Server(...):
await done.wait()
In the longer term, I see the convenience of an async equivalent of Server.forever()
. I am not immediately sure where to add it. async/await can't appear in src/p4p/server/__init__.py
as long as py2.7 is supported. I am not sure it would be worthwhile to add p4p.server.asyncio.Server
just to add one classmethod. Maybe a helper method p4p.server.asyncio.serve_forever()
?
Description
Server.forever
doesn't work with asyncSharedPV
s, probably due to this sleep:https://github.com/mdavidsaver/p4p/blob/f5c96bad937fff57f5243f72b7fdb89a408d0f4a/src/p4p/server/__init__.py#L175
To reproduce:
Run the following server:
Then run
pvput foo 12
Observed behaviour
pvput
times out:Expected behaviour
pvput
succeeds and updates the value