Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fails to get services on Windows 11 when pkg_resources is imported and pywin32 package is installed #1132

@zapta

Description

@zapta
  • bleak version:
  • Python version:
  • Operating System:
  • BlueZ version (bluetoothctl -v) in case of Linux:

Win 11 Pro
OS: Windows-10-10.0.22621-SP0
Platform:: uname_result(system='Windows', node='DESKTOP-T0P7657', release='10', version='10.0.22621', machine='AMD64')
Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)]

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

I have a a Python application that in some cases hangs when trying to establish a connection via Bleak. I reduced it to a small example that demonstrate the problem.

To reproduce:

  1. Use Win 11. The issue doesn't exist under Win 10.
  2. Use python 3.10.7 (I didn't try with other versions).
  3. Start with all python packages removed. E.g. https://gankrin.org/how-to-remove-all-python-packages-installed-by-pip/
  4. Install these python packages: pip install -r requirements_broken.txt . Use this file https://github.com/zapta/ble_stepper_motor_analyzer/blob/main/python/requirements_broken.txt
  5. Update the device address in https://github.com/zapta/ble_stepper_motor_analyzer/blob/main/python/bleak_test_broken.py and run it to connect to your device. For me it fails consistently with this log https://pastebin.com/TnWgfWWG .

Two points that may help diagnosing the issue:
i. Uninstalling the ipykernel pip package also makes it to work.
ii. Removing 'import pkg_resources' from the test program makes it to work. (However, I do need it in my real application)

What I Did

It is preferable if an issue contains a Miminal Workable Example.
This will otherwise be one of the first questions you will get as a response.

It is also preferable if that example is not dependent on a specific peripheral device, but can be run and
reproduced with other BLE peripherals as well.

See example above. It's a subset of my full application.

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here as well.

Logs

Include any relevant logs here.

Logs are essential to understand what is going on behind the scenes.

See https://bleak.readthedocs.io/en/latest/troubleshooting.html for information on how to collect debug logs.

If you receive an OS error (WinError, BleakDBusError, NSError, etc.), Wireshark logs of Bluetooth packets are required to understand the issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backend: WinRTIssues or PRs relating to the WinRT backendbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions