language_tool_python icon indicating copy to clipboard operation
language_tool_python copied to clipboard

spell checker displays output then gets stuck in IDLE

Open gaurav-95 opened this issue 3 years ago • 11 comments

This is my code, I am adding bullets wherever there is a new line and then trying to get spell-checked texts stored in res

import language_tool_python
#tool = language_tool_python.LanguageTool('en-US', config={ 'cacheSize': 1000, 'pipelineCaching': True })

text = 'A sentence with a error in the Hitchhiker’s Guide tot he Galaxy\n. Bet there is something here.\n Bests goats are in town.'
lines = text.split('\n\n' or '\n')
lines = [ "• " + para for para in lines]
res = "\n\n".join(lines)
with language_tool_python.LanguageTool('en-US', config={ 'cacheSize': 1000, 'pipelineCaching': True }) as tool:
  # do stuff with `tool`
    result = tool.correct(res)
    print(result)

I get an output of the corrected text. But there is no error, no other output. Just freezes there. I tried giving explicit close and using with statement as well to no avail.

gaurav-95 avatar Apr 06 '22 16:04 gaurav-95

Thanks for reporting @gaurav-95. So to be clear, the print(result) line actually prints? But then the closing of the with statement hangs?

jxmorris12 avatar Apr 06 '22 16:04 jxmorris12

@gaurav-95 I just tried running this on my machine and it runs fine - result is printed, and nothing freezes. Please reopen if you're still having issues.

jxmorris12 avatar Apr 17 '22 20:04 jxmorris12

Will check again and post output.

gaurav-95 avatar Apr 18 '22 00:04 gaurav-95

Yes, i can confirm that the output gets printed but the code keeps running on the terminal. It does not finish/ exit from runtime.

image

gaurav-95 avatar Apr 18 '22 02:04 gaurav-95

I think we can diagnose this issue as: self._terminate_server() not killing server on Windows. That's the most likely cause.

It's difficult for me to debug without a windows machine...

jxmorris12 avatar Apr 23 '22 15:04 jxmorris12

I see, my bad to not mention I was running on windows beforehand.

gaurav-95 avatar Apr 23 '22 16:04 gaurav-95

@jxmorris12 - I'm not getting any hard freezes on Windows 10, but I do have a likely-related problem where the java.exe process never ends even after IDLE is closed.

image

At one point I ended up with 20+ java.exe processes running hours after I had finished what I was doing.

Also, each Java process that's running seems to make the script's startup slower. It flashes a window briefly at the bottom of Windows one time for every current process, so if you have 10 java.exe processes running then it'll flash 10 times before the language tool object is successfully created.

Here's the only code required to reproduce the issue:

tool = language_tool_python.LanguageTool('en-US')

Pikamander2 avatar May 04 '22 05:05 Pikamander2

@Pikamander2 thanks for reporting, this is a serious issue. Are you running that code in a script? Or through the python IDLE?

jxmorris12 avatar May 04 '22 13:05 jxmorris12

@jxmorris12 - I just tested out the process bug in both CMD and IDLE and it looks like this bug also only occurs with IDLE.

In regards to Windows testing, one option that you could try is to run an evaluation copy of Windows in a virtual machine. Alternatively, a Windows VPS is about $5 per month.

Pikamander2 avatar May 04 '22 18:05 Pikamander2

This SO answer looks relevant: https://stackoverflow.com/a/55411153/2287177

jxmorris12 avatar May 05 '22 19:05 jxmorris12

Sorry for reviving this, I might have some info that can help.

I see this hanging issue upon calling tool.close() in WSL and in the pydev debugger on top of the previously mentioned terminals.

Weird that this works on my linux machine but not in WSL (running Ubuntu 20)

bMorgan01 avatar Nov 25 '22 02:11 bMorgan01