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

OSError: [WinError 10048] on spawning of PtyProcess #86

Closed
dalito opened this issue Jan 20, 2018 · 3 comments
Closed

OSError: [WinError 10048] on spawning of PtyProcess #86

dalito opened this issue Jan 20, 2018 · 3 comments

Comments

@dalito
Copy link
Contributor

dalito commented Jan 20, 2018

This is a follow up of #85. (Pywintypes 0.5.1, Win7, Python-3.6.4-64bit)

If a socket is already in use, an OSError is raised on Windows. However, _get_address increments the port number only for socket.error but not for OSError.

Changing the code to increment the port number on OSError solves the problem 99% of the time. However, sometimes another process acquires the port between _get_address (where the port is closed at the end) and the bind operation in PtyProcess.init(...). I think it is not a good idea to separate _get_adress from the actual bind in PtyProcess.init(...).

@dalito
Copy link
Contributor Author

dalito commented Jan 20, 2018

Hmm. This

If a socket is already in use, an OSError is raised on Windows. However, _get_address increments the port number only for socket.error but not for OSError.

is not correct according to Python socket documentation. Maybe the only problem is that get_address is separated from the bind operation and it was pure luck that I did get the error less often after my code modification.

@ccordoba12
Copy link
Contributor

Could you open a pull request for this? Thanks!

@dalito dalito changed the title Pywinpty does not recognised used port on windows OSError: [WinError 10048] on spawning of PtyProcess Jan 22, 2018
@dalito
Copy link
Contributor Author

dalito commented Jan 22, 2018

Just for completeness: The error message was

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from winpty import PtyProcess
>>> proc = PtyProcess.spawn('python')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\dev_src\_pyve\stable_py36\lib\site-packages\winpty\ptyprocess.py", line 113, in spawn
    inst = cls(proc)
  File "c:\dev_src\_pyve\stable_py36\lib\site-packages\winpty\ptyprocess.py", line 47, in __init__
    self._server.bind(address)
OSError: [WinError 10048] Normalerweise darf jede Socketadresse (Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet werden

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

No branches or pull requests

2 participants