import multiprocessing
def process(objs):
global df1
with open(objs[0], "r") as f:
text = f.readline()
text = text.replace("\n", "")
df1.loc[objs[1], "text"] = text
p = multiprocessing.Pool()
p.apply_async(process, [["../../texts/" + row.text, i] for i, row in tqdm(df1[index].iterrows(), total=df1[index].shape[0])],
)
p.close()
p.join() # Wait for all child processes to close.
Например, если вы записываете в csv только каждый 10000й файл, зачем вы вообще открываете и обрабатываете остальные 9999 файлов?
import multiprocessing
c1 = 0
class Result():
def __init__(self, df):
self.df = df
def update_result(self, df):
self.df = df
def process(file,i, df1):
with open(file, "r") as f:
text = f.readline()
text = text.replace("\n", "")
df1.loc[i, "text"] = text
return df1
p = multiprocessing.Pool()
index = df1.text.str.contains("texts/")
result = Result(df1)
for i, row in tqdm(df1[index].iterrows(), total=df1[index].shape[0]):
c1 += 1
p.apply_async(process, ["../../" + row.text, i, df1],
callback=result.update_result)
if c1 % 10000 == 0:
print(result.df[index].shape[0]) #не изменяется!
result.df.to_csv("temp.csv", index=False)
p.close()
p.join()
for i, row in df.iterrows():
path = row.path
with subprocess.Popen(f"echo {password} | sudo -S ./recog_wav.sh {path}",
stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) as proc:
try:
outs, errs = proc.communicate(timeout=200)
except subprocess.TimeoutExpired:
proc.kill()
outs, errs = proc.communicate()
ourLib/
|---ourLib/
|--- __init__.py
|--- video/
|--- texts/
|---__init__.py
|---metrics/__init__.py
|---requirements.txt
|---setup.py
ourLib/
|---ourLib/
|--- video/
|--- texts/
|---metrics/__init__.py
|---requirements.txt
|---setup.py
When using a secure websocket connection (wss://) with a self-signed certificate, the connection from a browser may fail because it wants to show the “accept this certificate” dialog but has nowhere to show it. You must first visit a regular HTML page using the same certificate to accept it before the websocket connection will succeed.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
upstream ws_server {
server ws_server:5100;
}
server {
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
listen 80;
server_name localhost;
location /ws {
proxy_pass http://ws_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 950s;
proxy_set_header Host $http_host;
}
}
}