Repository navigation
analyze() takes a timeout - #47
Merged
ddehilster merged 1 commit intoOct 27, 2026
Merged
Conversation
ddehilster
added a commit
to ddehilster/py-package-nlpengine
that referenced
this pull request
Oct 27, 2026
package-analyzers a53e9e2 and the zone rework now split "kenethfpp at mails dot yahoo dot uk" into subdomain/domainname/cd and keep the local part of "charitysc123 at 243 dot org". The stored output predated both, so test_emailaddress_parser failed on every PR (also VisualText#47). Regenerated with nlp 4.2.48 and the pinned package-analyzers commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An NLP++ analyzer whose loop never ends could only be stopped by killing the process, and one that makes a string a turn got there by itself, out of memory. Engine 4.2.41 can stop a run at a limit; this passes one through. - Engine.analyze(..., timeout=seconds) and NLPPlus.analyze(..., timeout=). None, the default, is no limit, as before. - A run stopped at it raises AnalysisStopped, which carries the analyzer name and the timeout. It is an EngineException and also an Exception, so ordinary error handling catches it, which EngineException alone (a BaseException) does not. - The binding takes timeout in analyze() and exposes last_run_stopped(). TimeoutTest builds a throwaway analyzer that loops forever: it is stopped, the pass after it does not run, and the same Engine then runs an analyzer that finishes, with and without a timeout. Needs the nlp-engine submodule at 4.2.41 or later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ddehilster
force-pushed
the
feat/analyze-takes-a-timeout
branch
from
October 27, 2026 18:58
c7afa9d to
5888838
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An NLP++ analyzer whose loop never ends could only be stopped by killing the process. One that makes a new string every turn gets there by itself, by running out of memory: in production, one such grammar took a document extractor down five times in half an hour. Engine 4.2.41 (VisualText/nlp-engine#800, released in 4.2.42 / NLPPlus 2.2.73) can stop a run at a time limit. This passes the limit through.
API
Engine.analyze(..., timeout=seconds)andNLPPlus.analyze(..., timeout=).None, the default, means no limit, as before.AnalysisStopped, which carries the analyzer name and the timeout. It's anEngineExceptionand also anException, so ordinaryexcept Exceptionhandling catches it.EngineExceptionalone wouldn't be caught, because it derives fromBaseException.timeoutinanalyze()and exposeslast_run_stopped().The engine stops the run at its next
whileturn or pass, skips the passes after it, and frees what it built, so the sameEngineis fit for the next call.Tests:
TimeoutTestbuilds a throwaway analyzer that loops forever, and checks that:AnalysisStoppedis raised and is anException;Enginethen runs an analyzer that finishes, with and without a timeout.Run locally against this engine on Windows, all three pass. The four other tests that fail locally (
test_simple,test_emailaddress_parser,test_repeated_analyze_same_process,test_multibyte_words_survive_single_byte_locale) fail the same way on an unmodifiedmainbuilt the same way, so they're about the local environment, not this change. CI here is the real check.🤖 Generated with Claude Code