Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip link detection in Windows #303

Closed
wants to merge 1 commit into from

Conversation

aivarannamaa
Copy link

If p is a Serial over Bluetooth link, then os.path.islink(p) may take several seconds.

In two of my Windows 10 computers following code used to take 5 seconds:

from serial.tools.list_ports import comports
for p in comports():
    print(p)

I found out that the delay was caused by os.path.islink('COM5'). COM5 is one of the "Bluetooth over serial" ports backed by LogiLink Bluetooth dongle.

After my change it takes 0.01 seconds.

If I'm not mistaken, then list_ports_windows can't list symlinks anyway, so this time consuming check can be turned off for Windows.

If `p` is a Serial over Bluetooth link, then `os.path.islink(p)` may take several seconds.
@zsquareplusc
Copy link
Member

Right, that could be skipped.

What I do not like is that this introduces a new method to check for the platform and makes that module platform dependent too. I guess it easier to add a parameter to the ListPortInfo constructor. I've implemented that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants