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

[bug] missing subprocess module in some Windows installations makes JsonServer to don't kill himself after ST3 is closed #287

Closed
finalinches opened this issue Mar 4, 2015 · 17 comments

Comments

@finalinches
Copy link

my os is win 8.1, i user the sublime text 3(BUILD 3065)
my anaconda version is 1.4.3

when i exit the sublime,just close it
there are some python.exe still stay in my os and listen some tcp port

i have a test, when i close ST3, after some hours, i find python.exe still exist........, except i kill the python.exe

....................
so sorry open it again, but in my system it's really exist python.exe, every i time i have to kill python.exe after close the ST3

@DamnWidget
Copy link
Owner

You didn't need to create another issue you could re-open #286, anyway, anaconda checks that the Sublime Text 3 process is running every five seconds, if the process is not running, then it kills itself. I need more information as this never happened before to anyone.

Please, execute the steps below and paste here your results

  • Open your ST3 in a project that contains Python code so anaconda gets spawned
  • Open a console in your Sublime Text 3 (View -> Show Console) and write this on it: import os; os.getpid()
  • Copy the PID that you just got back from the action above, paste here and remember it as you are gonna use it in the next step
  • Open a PowerShell or a cmd.exe and write: tasklist /FI PID eq <write_here_the_PID_that_you_got>, paste it's output here.
  • In the same PowerShell or cmd.exe write: MIC path win32_process where "name like '%python%' get commandline, paste it's output here

@finalinches
Copy link
Author

the tasklist out
C:\Windows\system32>tasklist /FI "PID eq 8188"

Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
plugin_host.exe 8188 Console 1 67,664 K

In the same PowerShell or cmd.exe write: MIC path win32_process where "name like '%python%' get commandline, paste it's output here

i can't understand this option. In my system, i write this, get the output like:
C:\Windows\system32>MIC path win32_process where "name like '%python%' get comm
ndline
'MIC' is not recognized as an internal or external command,
operable program or batch file.

@DamnWidget
Copy link
Owner

That's because I had a typo, the command is WMIC

@finalinches
Copy link
Author

C:\Windows\system32>wmic path win32_process where "name like '%python%'" get com
mandline
CommandLine

D:/Python27/python.exe -B "D:\Program Files\Sublime Text\Data\Packages\Anaconda
anaconda_lib../anaconda_server\jsonserver.py" -p neutron 51344 -e "D:/work/open
cloud/Neutron/neutron/neutron,D:\work\opencloud\Neutron\neutron\neutron,D:\work
opencloud\Autotest Code\NetnodeTest,E:\Vmvare_Host\ShareDir\myboottest\template
web,D:\work\opencloud\安全BSS\BSS_server,D:\work\opencloud\proxy,D:\work\openclo
ud\Autotest Code\proxy_test" 8188

@DamnWidget
Copy link
Owner

Ok, now close your Sublime Text 3, wait one minute, run the tasklist command again to make sure that pugin_hosts is not zombie in your system and run the wmic command again.

Go to %APPDATA%\Jedi\Jedi\neutron and paste here the contents of the file anaconda_jsonserver.log

@finalinches
Copy link
Author

2015-03-04 22:17:03,907: DEBUG : bind: address=('localhost', 51344)
2015-03-04 22:17:03,907: DEBUG : listen: backlog=5
2015-03-04 22:17:03,969: INFO : Incomming connection from ('127.0.0.1', 51387)
2015-03-04 22:17:03,970: INFO : Incomming connection from ('127.0.0.1', 51388)
2015-03-04 22:17:04,323: INFO : client requests: lint
2015-03-04 22:17:04,346: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "ed3d758d62de4960819bb98973a37c0f", "success": true}

2015-03-04 22:40:15,941: INFO : client requests: lint
2015-03-04 22:40:15,964: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "51701e307b6d4275bc296ec11e5a6b60", "success": true}

2015-03-04 22:49:08,174: INFO : client requests: lint
2015-03-04 22:49:08,196: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "bcddc8106c994bf8b4cb7099d7ea83c6", "success": true}

2015-03-04 22:50:04,937: INFO : client requests: lint
2015-03-04 22:50:04,960: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "94d8d34c21b54fdf94ef148416e888fb", "success": true}

2015-03-04 22:50:09,124: INFO : client requests: lint
2015-03-04 22:50:09,144: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "f82e59e1c0d04fc0a780e87ae2964415", "success": true}

2015-03-04 23:09:51,301: INFO : client requests: lint
2015-03-04 23:09:51,332: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "9e85b78055254fadb59843349369256c", "success": true}

2015-03-04 23:10:23,125: INFO : client requests: lint
2015-03-04 23:10:23,144: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "0213be5f446f4fe4a1b68baf8c2ae5e6", "success": true}

2015-03-04 23:10:25,344: INFO : client requests: lint
2015-03-04 23:10:25,367: INFO : About push back to ST3: {"vid": 16, "errors": [], "uid": "3aea4f611c064f0691e7db80f6f7cdfd", "success": true}

@DamnWidget
Copy link
Owner

Which was the output of tasklist and wmic commands?

@finalinches
Copy link
Author

tasklist show that ST3 had been exit,no plugin_host process

but WMIC show that the python exe is still exist

@DamnWidget
Copy link
Owner

That's hard to believe, as you can see here, the JsonServer python process uses the same tasklist command to determine if the plugins_host process is still running, then, if the PID is not in the output it just sets the self.die variable as True that makes the thread to exit the loop effectively calling self.server.shutdown that closes the handler.

I don't have access no any Windows 8 machine but this is working fine in a Windows 7 VM that I use to test AnacondaST3 in windows platform. I will expect to get errors in the anaconda_jsonserver.log comming from the asyncore loop in case that the shutdown can't be done for some reason.

@finalinches
Copy link
Author

i have test code,and i find the code is hang at
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = subprocess.check_output(
['tasklist', '/FI', 'PID eq {0}'.format(PID)],
startupinfo=startupinfo
)

here,when you call the check_output, this command is not return

@DamnWidget
Copy link
Owner

Really weird, I will take a look into this issue as soon as I can install an OEM/Test Windows 8.1 VM

@finalinches
Copy link
Author

startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

Traceback (most recent call last):
File "<pyshell#4>", line 1, in
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
AttributeError: 'module' object has no attribute 'STARTF_USESHOWWINDOW'

@finalinches
Copy link
Author

i think this is the reason

my python is 2.7.1

@finalinches
Copy link
Author

ok, i have google the reason

i need to
import _subprocess

and use the
_subporcess.STARTF_USESHOWWINDOW

@finalinches
Copy link
Author

OK, that's ok, jsonsever will exit normally
import _subprocess
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW
output = subprocess.check_output(

@DamnWidget
Copy link
Owner

Cool, I will add an official fix for this in the next release :)

@DamnWidget DamnWidget changed the title when i exit the sublime,there are some python.exe stay in my os for ever [bug] missing subprocess module in some Windows installations makes JsonServer to don't kill himself after ST3 is closed Mar 4, 2015
@finalinches
Copy link
Author

:) ok,waiting the new release

@DamnWidget DamnWidget added this to the v1.4.4 milestone Mar 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants