Fix RFCOMM connect under uvloop and bump version to 0.1.4
This commit is contained in:
@@ -155,13 +155,18 @@ class RFCOMMClient:
|
||||
sock = _socket.socket(
|
||||
_socket.AF_BLUETOOTH, _socket.SOCK_STREAM, _socket.BTPROTO_RFCOMM
|
||||
)
|
||||
sock.setblocking(False)
|
||||
loop = asyncio.get_running_loop()
|
||||
try:
|
||||
await asyncio.wait_for(
|
||||
loop.sock_connect(sock, (self._address, self._channel)),
|
||||
timeout=10.0,
|
||||
# uvloop's sock_connect path goes through getaddrinfo and doesn't
|
||||
# support AF_BLUETOOTH addresses reliably. Use direct socket connect
|
||||
# in a thread instead.
|
||||
sock.settimeout(10.0)
|
||||
await loop.run_in_executor(
|
||||
None,
|
||||
sock.connect,
|
||||
(self._address, self._channel),
|
||||
)
|
||||
sock.setblocking(False)
|
||||
except asyncio.TimeoutError as exc:
|
||||
sock.close()
|
||||
raise PrinterTimeout(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: "Fichero Printer"
|
||||
version: "0.1.3"
|
||||
version: "0.1.4"
|
||||
slug: "fichero_printer"
|
||||
description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth"
|
||||
url: "https://git.leuschner.dev/Tobias/Fichero"
|
||||
|
||||
@@ -155,13 +155,18 @@ class RFCOMMClient:
|
||||
sock = _socket.socket(
|
||||
_socket.AF_BLUETOOTH, _socket.SOCK_STREAM, _socket.BTPROTO_RFCOMM
|
||||
)
|
||||
sock.setblocking(False)
|
||||
loop = asyncio.get_running_loop()
|
||||
try:
|
||||
await asyncio.wait_for(
|
||||
loop.sock_connect(sock, (self._address, self._channel)),
|
||||
timeout=10.0,
|
||||
# uvloop's sock_connect path goes through getaddrinfo and doesn't
|
||||
# support AF_BLUETOOTH addresses reliably. Use direct socket connect
|
||||
# in a thread instead.
|
||||
sock.settimeout(10.0)
|
||||
await loop.run_in_executor(
|
||||
None,
|
||||
sock.connect,
|
||||
(self._address, self._channel),
|
||||
)
|
||||
sock.setblocking(False)
|
||||
except asyncio.TimeoutError as exc:
|
||||
sock.close()
|
||||
raise PrinterTimeout(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "fichero-printer"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
description = "Fichero D11s thermal label printer - BLE CLI tool"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
Reference in New Issue
Block a user