Skip to content

Instantly share code, notes, and snippets.

@ArturTan
Created November 2, 2018 17:02
Show Gist options
  • Save ArturTan/93715e0be7ad539d35ee2fbdc8e13183 to your computer and use it in GitHub Desktop.
Save ArturTan/93715e0be7ad539d35ee2fbdc8e13183 to your computer and use it in GitHub Desktop.
morfeusz_execnet
import execnet
def token_converter(text):
gw = execnet.makegateway("popen//python=python2.7")
channel = gw.remote_exec(
"""import morfeusz2 as morf
import gc
def converter(text):
analyzer = morf.Morfeusz()
text = analyzer.analyse(text)
return text
text = channel.receive()
channel.send(converter(text))
del converter
del text
del morf
""")
channel.reconfigure(py2str_as_py3str=False)
channel.send(text)
text = channel.receive()
channel.close()
execnet.default_group.terminate()
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment