Closed sjlnk closed 8 years ago
A quick and dirty fix was to change LanguageTool._TIMEOUT to something smaller and put time.sleep(5) in between terminate and start commands to give the server some time to terminate.
This is the modified LanguageTool._get_root:
@classmethod
def _get_root(cls, url, data=None, num_tries=2):
for n in range(num_tries):
try:
with urlopen(url, data, cls._TIMEOUT) as f:
return ElementTree.parse(f).getroot()
except (IOError, http.client.HTTPException) as e:
cls._terminate_server()
import time; time.sleep(5) # wait for a while for the server to properly terminate
cls._start_server()
if n + 1 >= num_tries:
raise Error('{}: {}'.format(cls._url, e))
Obviously that hack is not a proper fix for the problem. That Java server should be ideally fixed. Is there any chance the communication with the server is flawed and causes these freezes?
I can reproduce the problem using your example. On my OS X machine (with Java 1.6 and LanguageTool 2.2), I consistently see it freeze at iteration 950.
I have also experienced this behavior, and have found the problem is compounded when attempting to use multiprocessing to detect the language of documents in multiple processes.
LanguageTool server keeps on freezing randomly. The client never receives the HTTP request.
This is the state of the client at the time of frozen server:
This is the error triggering sample script:
It normally freezes at around 900th-1000th iteration.
OS: Linux Mint Kernel: 3.13.0-24-generic Python: 3.4.3
java -version: