Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wait for response before returning #99

Open
sdumetz opened this issue Nov 2, 2019 · 0 comments
Open

wait for response before returning #99

sdumetz opened this issue Nov 2, 2019 · 0 comments

Comments

@sdumetz
Copy link

sdumetz commented Nov 2, 2019

Icurrently, when one uses communicator.send() to write a packet, he will soon get a ResponsePacket

The specification (ESP3) states that :
If the answer time between REQUEST/EVENT and RESPONSE exceeds 500ms a timeout is identified as well.

For now, RESPONSE handling and timeout detection is left to the user. Maybe it's by design to stay low level and not handle this logic? Otherwise, I think it would be nice to have some sort of blocking method like (naive implementation) :

def send(packet):
    global communicator
    communicator.send(packet)
    packet = communicator.receive.get(block=True, timeout=0.5) # spec-defined timeout is 500ms
    if isinstance(packet, ResponsePacket):
        print("got response : ", packet.response)
        return
    else:
        #fixme : queue-back this package?
        #throw error
        print ("non-response packet in send() : ", packet)

packages received when the communicator has a callback would have to always be queued, and we need something a bit more subtle to be able to re-queue packages that came when we were waiting for the ResponsePacket.

is some (refined & tested) version of this desirable or out of this library's scope?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant