From 3646d517a564e059507772f9e9d0f45fa15a6436 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sat, 5 May 2018 12:06:31 +0000 Subject: [PATCH] lib/beautifier.py: start subprocess using gevent --- lib/beautifier.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/beautifier.py b/lib/beautifier.py index 69f31d7..b7ee725 100644 --- a/lib/beautifier.py +++ b/lib/beautifier.py @@ -15,10 +15,14 @@ Exported functions: normalize(text, mode) """ +from gevent.monkey import patch_all +from gevent.subprocess import Popen +patch_all() + +# pylint: disable=wrong-import-position,wrong-import-order import sys import os import textwrap -import subprocess import hashlib import re @@ -27,7 +31,6 @@ from tempfile import NamedTemporaryFile import redis -# pylint: disable=wrong-import-position,wrong-import-order MYDIR = os.path.abspath(os.path.dirname(os.path.dirname('__file__'))) sys.path.append("%s/lib/" % MYDIR) from languages_data import VIM_NAME @@ -196,7 +199,7 @@ def _run_vim_script(script_lines, text_lines): cmd = ["script", "-q", "-c", "vim -S %s %s" % (script_vim.name, textfile.name)] - subprocess.Popen(cmd, shell=False, stdout=FNULL, stderr=FNULL, env=my_env).communicate() + Popen(cmd, shell=False, stdout=FNULL, stderr=FNULL, env=my_env).communicate() return open(textfile.name, "r").read()