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

Connection impossible via SerialServer #48

Open
bagl3y opened this issue Nov 20, 2024 · 4 comments
Open

Connection impossible via SerialServer #48

bagl3y opened this issue Nov 20, 2024 · 4 comments

Comments

@bagl3y
Copy link

bagl3y commented Nov 20, 2024

Bonjour,

J'utilise SerialServer pour me connecter à mon module TIC via le réseau.

Quand je tape mon url : rfc2217://192.168.42.239:2217 , j'ai une erreur : Erreur inattendue

Coté Logs HA, j'ai une error suivi d'une stacktrace :

2024-11-20 19:26:27.749 ERROR (MainThread) [custom_components.linkytic.config_flow] Unexpected exception: Caught blocking call to sleep with args (0.3,) inside the event loop by custom integration 'linkytic' at custom_components/linkytic/serial_reader.py, line 469: serial_reader = serial.serial_for_url(. (offender: /usr/local/lib/python3.12/site-packages/serial/rfc2217.py, line 557: time.sleep(0.3)), please create a bug report at https://github.com/hekmon/linkytic/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#sleep
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/serial/rfc2217.py", line 477, in open
    time.sleep(0.05)    # prevent 100% CPU load
    ^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 192, in protected_loop_func
    raise_for_blocking_call(
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 158, in raise_for_blocking_call
    raise RuntimeError(
RuntimeError: Caught blocking call to sleep with args (0.05,) inside the event loop by custom integration 'linkytic' at custom_components/linkytic/serial_reader.py, line 469: serial_reader = serial.serial_for_url(. (offender: /usr/local/lib/python3.12/site-packages/serial/rfc2217.py, line 477: time.sleep(0.05)    # prevent 100% CPU load), please create a bug report at https://github.com/hekmon/linkytic/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#sleep
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/config/custom_components/linkytic/config_flow.py", line 76, in async_step_user
    linky_tic_tester(
  File "/config/custom_components/linkytic/serial_reader.py", line 469, in linky_tic_tester
    serial_reader = serial.serial_for_url(
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/serial/__init__.py", line 90, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.12/site-packages/serial/rfc2217.py", line 496, in open
    self.close()
  File "/usr/local/lib/python3.12/site-packages/serial/rfc2217.py", line 557, in close
    time.sleep(0.3)
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 192, in protected_loop_func
    raise_for_blocking_call(
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 158, in raise_for_blocking_call
    raise RuntimeError(
RuntimeError: Caught blocking call to sleep with args (0.3,) inside the event loop by custom integration 'linkytic' at custom_components/linkytic/serial_reader.py, line 469: serial_reader = serial.serial_for_url(. (offender: /usr/local/lib/python3.12/site-packages/serial/rfc2217.py, line 557: time.sleep(0.3)), please create a bug report at https://github.com/hekmon/linkytic/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#sleep

Core: 2024.11.2
Supervisor: 2024.11.2
Operating System: 13.2
Interface utilisateur: 20241106.2

Essayé avec la version 2.0.7 et 3.0.0-beta4

@tomleglaunec
Copy link
Collaborator

Bonjour, il s'agit bien d'un bug de l'intégration, qui n'affecte à priori que l'utilisation via rfc2217

L'implémentation rfc2217 de pyserial utilise des appels bloquants à sleep, qui est empêché par HomeAssistant si appelé depuis la boucle d'évènement principale. L'intégration utilise un thread séparé mais l'initialisation de la communication au démarrage et le test de connexion lors de l'ajout d'un appareil ne s'exécute pas dans le contexte de ce thread.

Je travaille sur le correctif

@tomleglaunec
Copy link
Collaborator

tomleglaunec commented Dec 22, 2024

La pre-release 3.0.0-beta4 3.0.0-beta5 ne devrait plus présenter le problème, j'attends vos retours

@kumy
Copy link

kumy commented Dec 22, 2024

You probably mean 3.0.0-beta5 ;)
image

@kumy
Copy link

kumy commented Dec 22, 2024

Works for me thanks!

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

3 participants