Page 1 of 1

open() timeout

Posted: Sun Aug 15, 2021 1:56 pm
by jnbastoky
Why doesn't the open method eventually generate a timeout? I like being able to call open() instead of openWaitForAttachment() so that I don't have to wait for attachment in sequential order of several channels. I'd still expect the channel to eventually timeout and call the error function.

Re: open() timeout

Posted: Mon Aug 16, 2021 7:34 am
by fraser
Though that might make some sense in some applications, one of the main benefits of the non-timeout open() is that you can call it and not worry about timeouts. There are a lot of applications for opening a device before it is plugged in, and being able to freely plug/unplug it as you see fit. I'm sure there are other good reasons for it as well.

You could implement your own timeout after calling open on a channel, or make use of the Manager object to more tightly control the awareness of attached/detached channels.

Re: open() timeout

Posted: Sat Sep 18, 2021 1:39 pm
by jnbastoky
That make sense. I've landed on calling openWaitForAttachment() initially then in the exception handler when it timesout calling open() in case it connects later.

Code: Select all

try:
    self.io_channel.openWaitForAttachment(2000)
except PhidgetException as e:
    self._error(self.io_channel, e.code, e.description)
    self.io_channel.open()  # see if comes online later