Skip to content
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

BrokenPipeError in long-running process #21

Closed
nkruglikov opened this issue Apr 25, 2018 · 3 comments · Fixed by #27
Closed

BrokenPipeError in long-running process #21

nkruglikov opened this issue Apr 25, 2018 · 3 comments · Fixed by #27

Comments

@nkruglikov
Copy link

nkruglikov commented Apr 25, 2018

It seems that if the mystem process dies for some reason (e. g. OS kills it), the wrapper crashes with the BrokenPipeError. I think that such behavior is unwanted, but I am not sure this could be fixed easily. I fixed it in my long-running process with catching the BrokenPipeError on Mystem.lemmatize call and recreating a Mystem object if needed.

The traceback:

  File "/usr/local/lib/python3.5/dist-packages/pymystem3/mystem.py", line 264, in lemmatize
    infos = self.analyze(text)
  File "/usr/local/lib/python3.5/dist-packages/pymystem3/mystem.py", line 249, in analyze
    result.extend(self._analyze_impl(line))
  File "/usr/local/lib/python3.5/dist-packages/pymystem3/mystem.py", line 280, in _analyze_impl
    self._procin.write(text)
BrokenPipeError: [Errno 32] Broken pipe

P. S. I have also noticed similar behavior in interactive Jupyter Notebook scenario. If you kill a cell which uses a Mystem object, later calls to its lemmatize methods lead to BrokenPipeError, so you need to recreate the object.

@alexanderpanchenko
Copy link
Contributor

sorry for the late response and thanks for reporting this issue. I am currently also not sure how this can be fixed, but any ideas or better pull requests with fixes are welcome.

@vasinkd
Copy link
Contributor

vasinkd commented Oct 19, 2018

I believe simple catching of BrokenPipeError and mysteminstance.close(), mysteminstance.start() can solve this. Just tried to kill mystem process and follow this steps, it helps.

@alexanderpanchenko
Copy link
Contributor

alexanderpanchenko commented Oct 19, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants