Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

asrelo
Copy link
Contributor

@asrelo asrelo commented Oct 3, 2025

I apologize it took me way longer to figure out a potentially better solution to the problem posed in #3430 (tldr: CoreNLPServer starts a separate server process but does not shut it down if the process fails a status check, resulting in a resource leak).

The class CoreNLPServer has two interfaces: explicit start/stop methods and the context manager interface. Currently the __enter__/__exit__ methods just run the start/stop methods. With this PR:

  1. start will not stop the server process in case of status check failure (pre-Stop the CoreNLP server if a test connection to it cannot be established #3430 behavior);
  2. __enter__ will stop the server process in case the status checks in start fail.

This way a user can choose between automatic cleanup (with the context manager interface) and manual cleanup. To me, it kind of makes sense to leave the latter option, since the started server is running, NLTK just cannot connect to it via HTTP or the server doesn't report it's ready. Also, this variant of the fix also affects less users - only those who use the context manager interface. The PR includes updated docstrings.

I still believe the optimal solution to the resources leak is uncertain, given that there is currently no way for a user to get logs from a failed CoreNLP server process — all they can get from NLTK in this scenario is a generic exception, so I don't insist on this solution. Note also that this variant of the fix runs the stop method to stop a failed server process which does wait on it to exit.

asrelo added 2 commits October 3, 2025 13:02
…d when used via a context manager interface.

Prevent resources leak when a user prefers to use CoreNLPServer as a context
manager instead of calling start/stop methods directly.
Update docstrings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.