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

[READY] Implement shutdown handler #2245

Merged
merged 3 commits into from Jul 23, 2016
Merged

[READY] Implement shutdown handler #2245

merged 3 commits into from Jul 23, 2016

Conversation

micbou
Copy link
Collaborator

@micbou micbou commented Jul 14, 2016

This PR depends on ycm-core/ycmd#282.

We don't want to block Vim exit if the server takes too much time to answer the shutdown request so we use a timeout of 100ms for this request. In my experience, it takes ~5ms.

The YcmStopServer command only exists for testing purpose. It will be removed in the final version of this PR.

Fixes #876.


This change is Reviewable

@Valloric
Copy link
Member

:lgtm:

Nice!


Review status: 0 of 9 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


python/ycm/youcompleteme.py, line 130 [r1] (raw file):

  def _SetupServer( self ):
    self._available_completers = {}
    self._user_notified_about_crash = False

Actually, this should be inside __init__. The idea is to initialize all member var inside __init__ if for any reason, then so that future readers have an easy way of knowing what are all the member variables used in this class.

Of course, there's nothing wrong with setting a different value to the member var in other functions, but they should be declared in __init__. (I use "declare" here loosely because there's no such concept in Python; values are merely assigned. Here by "declare" I mean "assigned for the first time.")

Any instances where we have member vars declared outside of __init__ are an oversight.


Comments from Reviewable

@micbou
Copy link
Collaborator Author

micbou commented Jul 15, 2016

Review status: 0 of 9 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


python/ycm/youcompleteme.py, line 130 [r1] (raw file):

Previously, Valloric (Val Markovic) wrote…

Actually, this should be inside __init__. The idea is to initialize all member var inside __init__ if for any reason, then so that future readers have an easy way of knowing what are all the member variables used in this class.

Of course, there's nothing wrong with setting a different value to the member var in other functions, but they should be declared in __init__. (I use "declare" here loosely because there's no such concept in Python; values are merely assigned. Here by "declare" I mean "assigned for the first time.")

Any instances where we have member vars declared outside of __init__ are an oversight.

I see but these variables need to be reset when restarting the server. If we initialize them inside `__init__`, we will set them twice to the same value when starting the server for the first time. Should we reset them in the `RestartServer` method instead?

Comments from Reviewable

@Valloric
Copy link
Member

Review status: 0 of 9 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


python/ycm/youcompleteme.py, line 130 [r1] (raw file):

we will set them twice to the same value when starting the server for the first time.

Why is this a problem?

I'm fine with setting the var to None in the ctor and then to False elsewhere if that helps. But setting it to False straight away still seems like the best choice.

Should we reset them in the RestartServer method instead?

Up to you. All I'd like to see is all member vars set to something in the ctor so that the reader can easily see what are all the member vars used in the class.


Comments from Reviewable

@puremourning
Copy link
Member

Awesome.

:lgtm: with one comment.


Reviewed 7 of 9 files at r1, 3 of 4 files at r2.
Review status: 10 of 11 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


autoload/youcompleteme.vim, line 779 [r2] (raw file):

function! s:StopServer()
  py ycm_state.StopServer()

Does this work on py3 ? Isn't the command :py3 ?

IIRC we have a method or some script-local variable used to call the correct py command for PY2/PY3 ?


Comments from Reviewable

@micbou
Copy link
Collaborator Author

micbou commented Jul 16, 2016

Reviewed 1 of 1 files at r3.
Review status: 10 of 11 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


autoload/youcompleteme.vim, line 779 [r2] (raw file):

Previously, puremourning (Ben Jackson) wrote…

Does this work on py3 ? Isn't the command :py3 ?

IIRC we have a method or some script-local variable used to call the correct py command for PY2/PY3 ?

Oops, I added the command a long time ago before we bring Python 3 support. Fixed.

Comments from Reviewable

@micbou
Copy link
Collaborator Author

micbou commented Jul 16, 2016

Reviewed 1 of 4 files at r2.
Review status: 10 of 11 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


python/ycm/youcompleteme.py, line 130 [r1] (raw file):

Previously, Valloric (Val Markovic) wrote…

we will set them twice to the same value when starting the server for the first time.

Why is this a problem?

I'm fine with setting the var to None in the ctor and then to False elsewhere if that helps. But setting it to False straight away still seems like the best choice.

Should we reset them in the RestartServer method instead?

Up to you. All I'd like to see is all member vars set to something in the ctor so that the reader can easily see what are all the member vars used in the class.

These two variables are now initialized in the constructor.

Comments from Reviewable

@Valloric
Copy link
Member

Reviewed 6 of 9 files at r1, 4 of 4 files at r2, 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


.gitmodules, line 6 [r3] (raw file):

[submodule "third_party/ycmd"]
  path = third_party/ycmd
  url = https://github.com/micbou/ycmd

Don't forget to remove this. :)


Comments from Reviewable

@puremourning
Copy link
Member

Looks good, though it looks like there's a problem with the CI... do you need a rebase, or is it flaking?


Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


Comments from Reviewable

@micbou
Copy link
Collaborator Author

micbou commented Jul 16, 2016

Yes, a rebase was needed.


Reviewed 5 of 9 files at r1, 3 of 4 files at r2, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

Use shutdown request to stop ycmd server in a portable way.
Create a Server_test class for tests that need a server instance.
@micbou
Copy link
Collaborator Author

micbou commented Jul 23, 2016

Updated to latest ycmd. This is ready.


Reviewed 3 of 4 files at r5.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


.gitmodules, line 6 [r3] (raw file):

Previously, Valloric (Val Markovic) wrote…

Don't forget to remove this. :)

Removed.

Comments from Reviewable

@micbou micbou changed the title [WIP] Implement shutdown handler [READY] Implement shutdown handler Jul 23, 2016
@puremourning
Copy link
Member

:lgtm:


Reviewed 1 of 1 files at r4, 3 of 4 files at r5.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@vheon
Copy link
Contributor

vheon commented Jul 23, 2016

:lgtm: @homu r=puremourning


Reviewed 5 of 9 files at r1, 1 of 4 files at r2, 1 of 1 files at r4, 3 of 4 files at r5.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@homu
Copy link
Contributor

homu commented Jul 23, 2016

📌 Commit 4e94d7c has been approved by puremourning

@homu
Copy link
Contributor

homu commented Jul 23, 2016

⚡ Test exempted - status

@homu homu merged commit 4e94d7c into ycm-core:master Jul 23, 2016
homu added a commit that referenced this pull request Jul 23, 2016
[READY] Implement shutdown handler

This PR depends on ycm-core/ycmd#282.

We don't want to block Vim exit if the server takes too much time to answer the shutdown request so we use a timeout of 100ms for this request. In my experience, it takes ~5ms.

The `YcmStopServer` command only exists for testing purpose. It will be removed in the final version of this PR.

Fixes #876.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2245)
<!-- Reviewable:end -->
@micbou micbou deleted the shutdown branch October 1, 2016 15:00
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

5 participants