Skip to content

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Apr 17, 2022

  • This one should probably get a new release

  • We can retry so hard that we block the event loop

Fixes
2022-04-16 22:18:51 WARNING (MainThread) [asyncio] Executing <Task finished name=Task-3576 coro=<open_connection() done, defined at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/streams.py:25> exception=ConnectionRefusedError(61, "Connect call failed (192.168.107.200, 9999)") created at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:460> took 1.001 seconds

2022-04-18 16:02:03 WARNING (MainThread) [asyncio] Executing <Task finished name='Task-48613' coro=<open_connection() done, defined at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/streams.py:25> exception=ConnectionRefusedError(61, "Connect call failed ('192.168.107.6', 9999)") created at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:460> took 1.002 seconds
2022-04-18 16:02:04 WARNING (MainThread) [asyncio] Executing <Task finished name='Task-48615' coro=<open_connection() done, defined at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/streams.py:25> exception=ConnectionRefusedError(61, "Connect call failed ('192.168.107.6', 9999)") created at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:460> took 1.002 seconds

@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2022

Codecov Report

Merging #340 (351fb49) into master (d2581bf) will increase coverage by 0.17%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #340      +/-   ##
==========================================
+ Coverage   80.52%   80.69%   +0.17%     
==========================================
  Files          25       25              
  Lines        1715     1725      +10     
  Branches      237      240       +3     
==========================================
+ Hits         1381     1392      +11     
+ Misses        300      299       -1     
  Partials       34       34              
Impacted Files Coverage Δ
kasa/protocol.py 91.12% <100.00%> (+0.77%) ⬆️
kasa/smartstrip.py 87.73% <0.00%> (+0.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d2581bf...351fb49. Read the comment docs.

@bdraco bdraco force-pushed the no_retry_unrecoverable_error branch from dc05cc8 to cd398cd Compare April 17, 2022 08:36
- We can retry so hard that we block the event loop

Fixes
```
2022-04-16 22:18:51 WARNING (MainThread) [asyncio] Executing <Task finished name=Task-3576 coro=<open_connection() done, defined at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/streams.py:25> exception=ConnectionRefusedError(61, "Connect call failed (192.168.107.200, 9999)") created at /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:460> took 1.001 seconds
```
@bdraco bdraco force-pushed the no_retry_unrecoverable_error branch from cd398cd to 20bb804 Compare April 17, 2022 08:40
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

I'm fine with this, but is this a real issue considering we only retry a couple of times?

Also, did you try to add a short sleep between calls to see if that'd be enough? Having a pause in-between might (or also might not) also alleviate issues where the device is not responsive for the initial request and has no time to wake up to answer to the subsequent ones.

@bdraco
Copy link
Member Author

bdraco commented Apr 23, 2022

I'm fine with this, but is this a real issue considering we only retry a couple of times?

When I lost an access point due to a POE injector getting fried, my instance became unresponsive due to the event loop being blocked from all the retries.

Also, did you try to add a short sleep between calls to see if that'd be enough? Having a pause in-between might (or also might not) also alleviate issues where the device is not responsive for the initial request and has no time to wake up to answer to the subsequent ones.

In general the connection should already be open so we shouldn't have to retry so aggressively now. I would expect to get a timeout, and not one of the errors being checked here if the device is not responding right away which is still being handled the same.

@rytilahti
Copy link
Member

In general the connection should already be open so we shouldn't have to retry so aggressively now. I would expect to get a timeout, and not one of the errors being checked here if the device is not responding right away which is still being handled the same.

True, please add a short comment about this special handling for future reference and then it is good to go.

@bdraco
Copy link
Member Author

bdraco commented Apr 24, 2022

comment added

@rytilahti rytilahti merged commit d908a5a into python-kasa:master Apr 24, 2022
@bdraco
Copy link
Member Author

bdraco commented Apr 24, 2022

Would you do a new release? I think it would be a good time to bump home assistant before beta so we can address anything with modularize that needs tweaks

@rytilahti
Copy link
Member

rytilahti commented Apr 24, 2022

I was a bit hesitant to prepare a new one as the modularize merge touched so many internals and as I won't have much time to handle potential issues, but I will prepare 0.5.0 and if needed homeassistant can always step back using the current release.

@bdraco
Copy link
Member Author

bdraco commented Apr 24, 2022

I'll have time to fix issues during beta if they come up. Worst case we revert before we publish the stable release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants