open() timeout

Supporting 2.7 and 3.2+
Post Reply
jnbastoky
Phidgetsian
Posts: 14
Joined: Sun Apr 15, 2018 9:03 am
Contact:

open() timeout

Post 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.
fraser
Engineering
Posts: 138
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: open() timeout

Post 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.
jnbastoky
Phidgetsian
Posts: 14
Joined: Sun Apr 15, 2018 9:03 am
Contact:

Re: open() timeout

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests