We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
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)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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)
The text was updated successfully, but these errors were encountered: