-
Notifications
You must be signed in to change notification settings - Fork 57
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
close java after task completed #38
Comments
Well, @dhanyweb -- the quick fix is to run the following command: But we should get to the bottom of this. You run Python scripts using |
Facing the same issue. My snippet that uses language_tool_python:
This snippet is used by some other functions and then a flask endpoint uses those in the end. Any way to programmatically terminate this Java process here itself when it's done evaluating? These processes remain there blocking a lot of memory until I terminate the Flask server. I want to terminate these right when this function is returned or request is served. cc: @jxmorris12 |
Temporary fix:
Added this call before my function returns. |
Thanks @meet59patel -- but what's the root cause? It seems super weird that your code leaves lots of instances of language_tool_python running. |
Hi, I am also suffering under this. My program calls language tool often in a loop and the Java processes are remaining in the memory after each iteration. Can't we force kill the process after returning ? |
@cdr-chakotay can you share your code with me? (just the loop part) |
Sure: I start multiple processes via multiprocessing in order to speed up processing. (That is my loop):
The
That's basically how it works. |
Hi @cdr-chakotay - thanks! This is super helpful. A couple questions:
|
@cdr-chakotay can you try changing the loop to this? def countTypos( StringToCheck: str) -> tuple:
with language_tool_python.LanguageTool('de-DE') as tool_de:
# tool_en = language_tool_python.LanguageTool('en-US') not used
tool_de.enabled_rules_only = True
tool_de.enabled_rules = ['DOPPELUNG_MODALVERB', 'GERMAN_SPELLER_RULE', 'WEIS_ICH', 'MEIN_KLEIN_HAUS',
'DOPPELPERFEKT', 'EMPFOHLENE_GETRENNTSCHREIBUNG', 'DE_WIEDER_VS_WIDER',
'RAN_RUM_RAUF_REIN_RAUS_RUNTER', 'DE_WORD_COHERENCY']
matches = tool_de.check(StringToCheck)
TypoCounter: int = len(matches)
return tuple([TypoCounter, matches]) |
Hi @meet59patel @dhanyweb @cdr-chakotay -- with the latest release (2.6.3) this should be solved. You have two options:
Please feel free to reopen if you're still having issues! |
The with .. as statement does not work for me. But tool.close() does the trick! Thank you very much. This speeds up everything! |
Great! |
i have many java defunct process when running task in loop, and cause cpu usage and memory issues, any methode to close java after task completed?
58802 ? Z 0:22 [java]
58892 ? Z 0:22 [java]
58999 ? Z 0:24 [java]
59127 ? Z 0:37 [java]
59234 ? Z 0:32 [java]
59303 ? Z 0:29 [java]
59441 ? Z 0:36 [java]
The text was updated successfully, but these errors were encountered: