Skip to content

Commit 99d1d6c

Browse files
authored
Do not open serial connection when connecting to a socket:// (#13)
1 parent 1759a42 commit 99d1d6c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

serial_asyncio_fast/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,15 @@ async def create_serial_connection(
512512
Any additional arguments will be forwarded to the Serial constructor.
513513
"""
514514
parsed_url = urllib.parse.urlparse(url)
515+
is_socket = parsed_url.scheme == "socket"
516+
517+
if is_socket and "do_not_open" not in kwargs:
518+
kwargs["do_not_open"] = True
515519

516520
callback = partial(serial.serial_for_url, url, *args, **kwargs)
517521
serial_instance = await loop.run_in_executor(None, callback)
518522

519-
if parsed_url.scheme == "socket":
523+
if is_socket:
520524
transport, protocol = await loop.create_connection(
521525
protocol_factory, parsed_url.hostname, parsed_url.port
522526
)

0 commit comments

Comments
 (0)