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

[WIP] Named pipe cleanup #85

Closed
wants to merge 5 commits into from
Closed

Conversation

blink1073
Copy link
Collaborator

@blink1073 blink1073 commented Jan 19, 2018

Potential fix for #59.

@blink1073 blink1073 closed this Jan 19, 2018
@blink1073 blink1073 reopened this Jan 19, 2018
@blink1073
Copy link
Collaborator Author

@SimonBiggs @dalito, do you mind trying out the snippet below with these changes?

You can make the changes by overwriting the winpty_wrapper.py file locally with the raw contents of the file in this PR, found in python -c "import winpty; print(winpty.__path__[0])".

from winpty import PtyProcess

proc = PtyProcess.spawn('python')
proc.write('print("hello, world!")\r\n')
proc.write('exit()\r\n')
while proc.isalive():
	print(proc.readline())

@SimonBiggs
Copy link

I won't get a chance till I'm back on my work computer on Monday. (It's Friday evening here now).

@SimonBiggs
Copy link

If it's not resolved by then though I shall give it a go :)

@SimonBiggs
Copy link

(All Linux at home)

@dalito
Copy link
Contributor

dalito commented Jan 19, 2018

I still get the same two errors (the order is random). Here is the result:

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
>>> proc = PtyProcess.spawn('python')
>>> Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\dev_amd64\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\dev_amd64\Python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\dev_src\_pyve\stable_py36\Lib\site-packages\winpty\ptyprocess.py", line 337, in _read_in_thread
    data = pty.read(4096)
  File "C:\dev_src\_pyve\stable_py36\Lib\site-packages\winpty\winpty_wrapper.py", line 86, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

Do you have an idea why there are two different errors seen randomly? What can cause a timing problem?

Thanks for looking at this. I can continue to test possible fixes over the weekend.

@blink1073
Copy link
Collaborator Author

The port error is most likely due to an antivirus software or system policy limiting access to ports. The default port is 20128. Can you please try changing that line locally to default to 8888 (the one typically used by the Jupyter Notebook), to see if that clears it up? We could allow for an environment variable to set the default port if it is an issue. I'm still looking into the access violation...

@blink1073
Copy link
Collaborator Author

@dalito, I've updated the file in the PR with more debug info, and an attempt to read a second time if the first fails, can you please try that as well?

@dalito
Copy link
Contributor

dalito commented Jan 20, 2018

Here is the result

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
>>> proc = PtyProcess.spawn('python')
size 0
length 0
>>> conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 0
length 0
conout_pipe 392
size 8
length 8
conout_pipe 392
exception: access violation writing 0x0000000000000000
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\dev_src\_pyve\stable_py36\Lib\site-packages\winpty\winpty_wrapper.py", line 90, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\dev_amd64\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\dev_amd64\Python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\dev_src\_pyve\stable_py36\Lib\site-packages\winpty\ptyprocess.py", line 337, in _read_in_thread
    data = pty.read(4096)
  File "C:\dev_src\_pyve\stable_py36\Lib\site-packages\winpty\winpty_wrapper.py", line 93, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

@blink1073
Copy link
Collaborator Author

Unfortunately I am no closer to understanding what is going on here.

@SimonBiggs
Copy link

@blink1073 let me know if there is anything I can do. It might be possible to do a remote session if you wanted to do more hands on troubleshooting.

@SimonBiggs
Copy link

Just for reference here is me running the results of this pull request on my machine.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\sbiggs>python
Python 3.5.4 | packaged by conda-forge | (default, Aug 10 2017, 01:38:47) [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')
size 0
length 0
>>> conout_pipe 348
proc.write('print("hello, world!")\r\n')
size 0
length 0
conout_pipe 348
24
>>> size 0
proc.write('exit()\r\n')
length 0
conout_pipe 348
8
size 0
>>> length 0
while proc.isalive():
conout_pipe 348
size 0
... length 0
        print(proc.readline())conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 0
length 0
conout_pipe 348
size 8
length 8
conout_pipe 348
exception: access violation writing 0x0000000000000000
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\sbiggs\AppData\Local\Continuum\Miniconda3\lib\site-packages\winpty\winpty_wrapper.py", line 88, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\sbiggs\AppData\Local\Continuum\Miniconda3\lib\threading.py", line 914, in _bootstrap_inner
    self.run()
  File "C:\Users\sbiggs\AppData\Local\Continuum\Miniconda3\lib\threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\sbiggs\AppData\Local\Continuum\Miniconda3\lib\site-packages\winpty\ptyprocess.py", line 331, in _read_in_thread
    data = pty.read(4096)
  File "C:\Users\sbiggs\AppData\Local\Continuum\Miniconda3\lib\site-packages\winpty\winpty_wrapper.py", line 91, in read
    ReadFile(self.conout_pipe, data, length, None, None)
OSError: exception: access violation writing 0x0000000000000000

@SimonBiggs
Copy link

As an extra step our IT administrator temporarily disabled my antivirus. This didn't stop the OSError from occuring.

@dalito
Copy link
Contributor

dalito commented Jan 25, 2018

To add to @SimonBiggs tests: Also when run as admin the error stays.

@ccordoba12
Copy link
Contributor

@dalito, so this is not fixed by your PR?

@dalito
Copy link
Contributor

dalito commented Jan 25, 2018

I got two different errors randomly: This one and the "OSError: [WinError 10048]" which is fixed by #87. After applying #87 there will only be this error for me.

@andfoy
Copy link
Owner

andfoy commented Jan 25, 2018

AFAIK, this is a problem related to the Python distribution itself. The strange fact is that it should be resolved

@SimonBiggs
Copy link

SimonBiggs commented Jan 26, 2018 via email

@ccordoba12
Copy link
Contributor

@SimonBiggs, could you see what happens in Python 3.6?

@SimonBiggs
Copy link

SimonBiggs commented Jan 28, 2018 via email

@ccordoba12
Copy link
Contributor

@blink1073, what to do about this PR? Do you want to close or merge it?

@blink1073
Copy link
Collaborator Author

Closing, not sure what else to try here.

@blink1073 blink1073 closed this Feb 6, 2018
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.

5 participants