8000 Monkey-patch a weakref set in Task to be a no-op. by bbangert · Pull Request #3639 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Monkey-patch a weakref set in Task to be a no-op. #3639

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
Oct 1, 2016

Conversation

bbangert
Copy link
Member
@bbangert bbangert commented Oct 1, 2016

Description:

Monkey-patches the asyncio.tasks.Task object to remove its weakref.WeakSet and __del__ method. These were both involved in causing seg-faults due to a Python bug (https://bugs.python.org/issue26617) that may not be addressed in a shipping Python for some time. The side-effect is that the Task.all_tasks() method will no longer work. If code relies on that method (nothing does that I've found thus far) then it will be inaccurate and throw an exception as the replacement object does not implement __iter__.

Related issue (if applicable): fixes #3453

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

Task.all_tasks() is no longer accurate, and there will be no
warning emitted if a Task is GC'd while in use.

On Python 3.6, after the bug is fixed, this monkey-patch can be
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have any bad side effects if it's still applied to 3.6? As long as 3.4 is supported, this would be needed, and I suspect that would be awhile because 3.4 is the latest on raspbian.

If that's the case, can it dynamically be only applied to python 3.4 and 3.5?

Copy link
Member

Choose a reason for hiding this comment

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

The bug is still open for 3.6 - we hope it will get fixed by 3.6.

https://bugs.python.org/issue26617

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really, I just noted it there in case anyone wanted to know when it should hopefully be fixed.

@balloob
Copy link
Member
balloob commented Oct 1, 2016

Code looks good 🐬 . Just some linting errors to address.

@balloob
Copy link
Member
balloob commented Oct 1, 2016

Don't fix them btw, as it makes no sense to fix them. Just disable them:

# pylint: disable=no-self-use, too-few-public-methods, protected-access
# pylint: disable=bare-except, wrong-import-order

@balloob balloob merged commit 892bbdc into dev Oct 1, 2016
@balloob balloob deleted the fix/monkey-patch-asyncio branch October 1, 2016 19:08
balloob pushed a commit that referenced this pull request Oct 1, 2016
* Monkey-patch a weakref set in Task to be a no-op.

* Fix linting issues
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random Segfaults
3 participants
0