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

Error when launch in docker #47

Open
konin-sergei opened this issue Apr 7, 2021 · 0 comments
Open

Error when launch in docker #47

konin-sergei opened this issue Apr 7, 2021 · 0 comments

Comments

@konin-sergei
Copy link

konin-sergei commented Apr 7, 2021

Hello.
I try to launch mystem in docker with multiprocessing and get error:
OSError: [Errno 26] Text file busy: '/root/.local/bin/mystem'

Dockerfile
FROM python:3.8-buster
WORKDIR /usr/src/app
COPY . .
RUN python3.8 -m pip install --upgrade pip
RUN python3.8 -m pip install --no-cache-dir pymystem3
CMD ["python3.8", "script.py"]

script.py
import multiprocessing
import time
from pymystem3 import Mystem
def lemma(data):
process_n = data[0]
texts = data[1]
print("process_n", process_n, "Создали Mystem()")
m = Mystem()
lemma_text = m.lemmatize(' '.join(texts))
m.close()
print("process_n", process_n, "Закрыли Mystem()")
return lemma_text

def lemmatisation_text():
n_core = 4
texts = ['Мама моет раму, Рама держит маму.' for x in range(1000)]
# Добавим номера процессов
params = [[core, texts] for core in range(n_core)]
print('pool start')
pool = multiprocessing.Pool(n_core)
print('pool map')
res = pool.map(lemma, params)
print('pool close')
pool.close()
print('pool join')
pool.join()
print(len(res))

if name == 'main':
start = time.time()
lemmatisation_text()
print(time.time() - start)

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

No branches or pull requests

1 participant