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