8000 Plug file leak on LIFX unregister by amelchio · Pull Request #7031 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Plug file leak on LIFX unregister #7031

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

Merged
merged 2 commits into from
Apr 11, 2017
Merged

Conversation

amelchio
Copy link
Contributor

Description:

The aiolifx 0.4.4 release closes its socket when the unregister callback is
called. This plugs a file descriptor leak but also means that we must be
careful to not use the device after it goes unavailable.

Also, when a light reappears, it has a new device that must be used.

Related issue (if applicable): fixes #6985

Checklist:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully.
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.

The aiolifx 0.4.4 release closes its socket when the unregister callback is
called. This plugs a file descriptor leak but also means that we must be
careful to not use the device after it goes unavailable.

Also, when a light reappears, it has a new device that must be used.
@mention-bot
Copy link

@amelchio, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @flyte and @balloob to be potential reviewers.

@@ -265,6 +269,9 @@ def async_turn_on(self, **kwargs):
@asyncio.coroutine
def async_turn_off(self, **kwargs):
"""Turn the device off."""
if not self.available:
return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if that make more sense to use it on Export_entity on ServiceComponent...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove that, I will make a PR for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. It was already in async_update before, can I remove it from there as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No update is needed, otherwise the device have no access to come back to available state. On update you need check if the device back to controll or stay available until next update call. But update is only needed on a polling device. If you have a callback and no polling device, you can update the property on callback function.

The core will learn to handle that.
@balloob balloob added this to the 0.42.3 milestone Apr 11, 2017
@balloob balloob merged commit f099aee into home-assistant:dev Apr 11, 2017
balloob pushed a commit that referenced this pull request Apr 11, 2017
* Plug file leak on LIFX unregister

The aiolifx 0.4.4 release closes its socket when the unregister callback is
called. This plugs a file descriptor leak but also means that we must be
careful to not use the device after it goes unavailable.

Also, when a light reappears, it has a new device that must be used.

* Do not test self.available in service calls

The core will learn to handle that.
@balloob balloob mentioned this pull request Apr 11, 2017
@balloob
Copy link
Member
balloob commented Apr 11, 2017

Cherry picked for 0.42.3

@amelchio
Copy link
Contributor Author

@balloob Hmm, the change that @pvizeli requested makes this PR depend on #7045.

amelchio added a commit to amelchio/home-assistant that referenced this pull request Apr 16, 2017
After home-assistant#7031 the LIFX device will change during an unregister/register
transition. This has the user-visible effect of the new device missing
a friendly name until the next poll.

We now cache the name internally and it will then transfer to the new
device when it registers.
balloob pushed a commit that referenced this pull request Apr 17, 2017
* Cache the name of LIFX lights

After #7031 the LIFX device will change during an unregister/register
transition. This has the user-visible effect of the new device missing
a friendly name until the next poll.

We now cache the name internally and it will then transfer to the new
device when it registers.

* Allow LIFX logging even without an available device

This will allow us to set the device to None when it unregisters.

* Calculate LIFX availability from the existence of a device

This has become possible because the device is no longer needed
to provide the name of the light when it is unavailable.

We just have to forget the device when it unregisters.
@balloob balloob mentioned this pull request Apr 21, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Jul 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lifx seems to be "leaking" open files
5 participants
0