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

[BUG] - Detected blocking call #379

Closed
MrRickwi opened this issue Apr 11, 2023 · 15 comments
Closed

[BUG] - Detected blocking call #379

MrRickwi opened this issue Apr 11, 2023 · 15 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@MrRickwi
Copy link

Describe the bug
In the log there are a lot of entries reporting a blocking interface call.

Mandatory details

  1. Integration Version: 2023.03.1
  2. HA Version: 2023.4.2
  3. Inverter Brand: SolaX 7 / Q-Cells
  4. Plugin Used:
  5. First 6 digits of Serial:
  6. Connection Method: RS485 / Modbus / USB

Detailed Error Log
In the log, I see a lot of entries like this one:

2023-04-11 17:21:07.709 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for solax_modbus doing blocking calls at custom_components/solax_modbus/__init__.py, line 318: return self._client.read_holding_registers(address, count, **kwargs)

Additional context
None

@wills106
Copy link
Owner

This is listed as No2 for Known Issues and a workaround.

@MrRickwi
Copy link
Author

Sorry, didn't see that section. Thanks for the hint. However, would it make sense to remove that blocking call?

@wills106
Copy link
Owner

There aren't any active developers connecting over Serial / RS485-USB.

My Inverter has built in Ethernet, so I have never had a need to connect with an RS485 - USB adaptor.

@MrRickwi
Copy link
Author

So, now there are ;-) Will play around with the code and see if I find a fix for that...

@wills106 wills106 added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Apr 25, 2023
@wills106 wills106 changed the title [BUG] [BUG] - Detected blocking call Apr 25, 2023
@wills106
Copy link
Owner

Any joy with improving the Serial connection part of the Integration?

@MrRickwi
Copy link
Author

Unfortunately I had no time to do some work for that...

@ZdenekM
Copy link

ZdenekM commented Jun 2, 2023

I just briefly looked at the code - the thing is that (at least) methods read_holding_registers and read_input_registers will have to become async, and the return self._client.read_xxx_registers(address, count, **kwargs) shall become something like return await asyncio.run_in_executor(None, functools.partial(self._client.read_xxx_registers, address, count, **kwargs)) and all methods where this is called from should also become async.

@FloCodeRian
Copy link

FloCodeRian commented Nov 11, 2023

I´m experiencing the same problem. Hope there is a fix for it. Blows me up my logs :/

2023-11-11 11:31:17.657 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop by custom integration 'solax_modbus' at custom_components/solax_modbus/init.py, line 350: return self.client.read_input_registers(address, count, **kwargs), please create a bug report at https://github.com/wills106/homsassistant-solax-modbus/issues
2023-11-11 11:31:17.685 WARNING (MainThread) [homeassistant.util.async
] Detected blocking call to sleep inside the event loop by custom integration 'solax_modbus' at custom_components/solax_modbus/init.py, line 350: return self.client.read_input_registers(address, count, **kwargs), please create a bug report at https://github.com/wills106/homsassistant-solax-modbus/issues
2023-11-11 11:31:17.715 WARNING (MainThread) [homeassistant.util.async
] Detected blocking call to sleep inside the event loop by custom integration 'solax_modbus' at custom_components/solax_modbus/init.py, line 350: return self._client.read_input_registers(address, count, **kwargs), please create a bug report at https://github.com/wills106/homsassistant-solax-modbus/issues

running on

Core 2023.11.2
Supervisor 2023.11.0
Operating System 11.1
homeassistant-solax-modbus 2023.11.2

@wills106
Copy link
Owner

There is a link to a workaround on the second post of this issue.

@FloCodeRian
Copy link

This is listed as No2 for Known Issues and a workaround.

Hi there, I did the insert the fix some day´s ago, several restart later, but it didn't worked for me. My logfile´s are still blown up because of:

2023-11-21 19:31:35.736 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop by custom integration 'solax_modbus' at custom_components/solax_modbus/init.py, line 344: return self.client.read_holding_registers(address, count, **kwargs), please create a bug report at https://github.com/wills106/homsassistant-solax-modbus/issues
2023-11-21 19:31:35.767 WARNING (MainThread) [homeassistant.util.async
] Detected blocking call to sleep inside the event loop by custom integration 'solax_modbus' at custom_components/solax_modbus/init.py, line 350: return self._client.read_input_registers(address, count, **kwargs), please create a bug report at https://github.com/wills106/homsassistant-solax-modbus/issues

@wills106
Copy link
Owner

Closing down as no active developers to look at correcting the Modbus Serial code.

@wills106
Copy link
Owner

wills106 commented Feb 22, 2024

I have just released 2024.02.6b4 does the work @Zwer2k has done on the async reard / writes prevent the need to hide the blocking call warnings?
Read the Docs - Detected Blocking Call

Edit: Changed to 2024.02.6b4

@wills106 wills106 reopened this Feb 22, 2024
@FloCodeRian
Copy link

Seems like working well for me. Can´t see any blocking calls unto the last running 4 hours

THX

@wills106
Copy link
Owner

Just released 2024.02.6 so closing this issue down again.

@MrRickwi
Copy link
Author

MrRickwi commented Feb 23, 2024

Tested the released version and it works perfectly without any need to configure logging. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants