Fix turbojpeg init doing blocking I/O in the event loop (#117971)

* Fix turbojpeg init doing blocking I/O in the event loop

fixes
```
Detected blocking call to open inside the event loop by integration camera at homeassistant/components/camera/img_util.py, line 100: TurboJPEGSingleton.__instance = TurboJPEG() (offender: /usr/local/lib/python3.12/ctypes/util.py, line 276: with open(filepath, rb) as fh:), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+camera%22
```

* Update homeassistant/components/camera/img_util.py

* Fix turbojpeg init doing blocking I/O in the event loop

fixes
```
Detected blocking call to open inside the event loop by integration camera at homeassistant/components/camera/img_util.py, line 100: TurboJPEGSingleton.__instance = TurboJPEG() (offender: /usr/local/lib/python3.12/ctypes/util.py, line 276: with open(filepath, rb) as fh:), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+camera%22
```

* already suppressed and logged
This commit is contained in:
J. Nick Koston 2024-05-23 04:50:25 -10:00 committed by GitHub
parent 6b2ddcca5e
commit 09e7156d2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,3 +103,9 @@ class TurboJPEGSingleton:
"Error loading libturbojpeg; Camera snapshot performance will be sub-optimal"
)
TurboJPEGSingleton.__instance = False
# TurboJPEG loads libraries that do blocking I/O.
# Initialize TurboJPEGSingleton in the executor to avoid
# blocking the event loop.
TurboJPEGSingleton.instance()