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

Process hangs after blatann.exceptions.InvalidStateException: Gattc Reader is busy #140

Open
jelledevleeschouwer opened this issue Aug 9, 2023 · 1 comment

Comments

@jelledevleeschouwer
Copy link

Hi @ThomasGerstenberg,

First of all, let me thank you for your work on the blatann package, it has been tremendously helpful to automate some tasks and test hardware.

Sometimes the exception from the title is raised, how that occurs is outside the scope of this issue. The issue I would like to report is that I seem to be unable to recover from it because the exception is raised in a different context from the main thread somewhere inside queued_tasks_manager.py:

Gattc Reader is busy
Traceback (most recent call last):
  File "C:\Users\JelledeVleeschouwerC\AppData\Local\Programs\Python\Python310\lib\site-packages\blatann\utils\queued_tasks_manager.py", line 35, in _add_task
    task_complete = self._handle_task(task)
  File "C:\Users\JelledeVleeschouwerC\AppData\Local\Programs\Python\Python310\lib\site-packages\blatann\gatt\managers.py", line 77, in _handle_task
    self._reader.read(task.handle)
  File "C:\Users\JelledeVleeschouwerC\AppData\Local\Programs\Python\Python310\lib\site-packages\blatann\gatt\reader.py", line 61, in read    
    raise InvalidStateException("Gattc Reader is busy")
blatann.exceptions.InvalidStateException: Gattc Reader is busy

This somehow causes my script to completely hang, so do you have any ideas how to recover from this properly?

Thanks in advance for your support,
Best regards,
Jelle

@ThomasGerstenberg
Copy link
Owner

Thank you for the kind words!

Without seeing any context, I'm guessing the program is hanging on a .wait() call. If that's the case ensure that each wait() call specifies a timeout value to avoid hanging indefinitely.

If you have a chance and can reproduce the issue, could you try running with blatann logs enabled that would help me find the root cause. Easiest way to enable logs is

from blatann.utils import setup_logger
setup_logger("blatann")

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

2 participants