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

DeviceTimeoutError #6

Open
brianmay opened this issue Feb 9, 2016 · 4 comments
Open

DeviceTimeoutError #6

brianmay opened this issue Feb 9, 2016 · 4 comments

Comments

@brianmay
Copy link

brianmay commented Feb 9, 2016

Seems that the library somehow gets into a weird state where it won't talk anymore to the light, and has to be restarted for it to work again.

Traceback (most recent call last):
  File "/home/lifx/python/local/lib/python2.7/site-packages/apscheduler/executors/base.py", line 112, in run_job
    retval = job.func(*job.args, **job.kwargs)
  File "/home/lifx/python/local/lib/python2.7/site-packages/wrapt/wrappers.py", line 522, in __call__
    args, kwargs)
  File "/home/lifx/python/local/lib/python2.7/site-packages/logtool/log_wrap.py", line 104, in __call__
    rc = fn (*args, **kwargs)
  File "./lifx_schedule", line 56, in set_white_color
    for l in lights.by_label('Main'):
  File "/home/lifx/python/local/lib/python2.7/site-packages/lifx/client.py", line 221, in by_label
    return filter(lambda d: d.label == label, self.get_devices())
  File "/home/lifx/python/local/lib/python2.7/site-packages/lifx/client.py", line 221, in <lambda>
    return filter(lambda d: d.label == label, self.get_devices())
  File "/home/lifx/python/local/lib/python2.7/site-packages/lifx/device.py", line 260, in label
    response = self._block_for_response(pkt_type=protocol.TYPE_GETLABEL)
  File "/home/lifx/python/local/lib/python2.7/site-packages/lifx/device.py", line 88, in _block_for_response
    return self._block_for(False, True, *args, **kwargs)
  File "/home/lifx/python/local/lib/python2.7/site-packages/lifx/device.py", line 136, in _block_for
    raise DeviceTimeoutError(self, timeout, DEFAULT_RETRANSMITS)
DeviceTimeoutError: Device with id:'d073d502abc8' timed out after 2.0 seconds and 10 retransmissions.

I believe the light in question is online and fully operational. Yes I know, the stack trace would imply otherwise.

@brianmay
Copy link
Author

Thinking about this, by_label() should never return DeviceTimeoutError as we are only trying to get a list of lights, not try to talk to them.

brianmay added a commit to brianmay/python-lifx-sdk that referenced this issue Mar 24, 2016
Previously get_device or the related functions would retrieve a list of
devices that it contacted in the last x seconds. Then we would contact
each light in turn to try and apply some sort of filtering.

This would error out if the light had been switched off.

This patch attempts to contact each light and skips it if it cannot be
contacted.

Closes smarthall#6
@brianmay
Copy link
Author

Still seems to be a problem in that if DeviceTimeoutError occurs in some situations it will forget about that light even if it is turned back on again. Still investigating.

@brianmay
Copy link
Author

Think we really should cache the label so we don't have to do a network access every time __repr__ is called on the light.

brianmay added a commit to brianmay/python-lifx-sdk that referenced this issue Mar 25, 2016
Previously get_device or the related functions would retrieve a list of
devices that it contacted in the last x seconds. Then we would contact
each light in turn to try and apply some sort of filtering.

This would error out if the light had been switched off.

This patch attempts to contact each light and skips it if it cannot be
contacted.

This also caches the label of the light so we can display the repr
string even if the light is offline.

Closes smarthall#6
@frakman1
Copy link

frakman1 commented Dec 8, 2016

I too have run into this. The code should really keep going instead of crashing like this. I shouldn't have to restart the script because of a momentary IP glitch.

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

2 participants