PY-29869 Improve skeletons generation for Docker Compose service based Python interpreter

Use Docker Compose container running the idle script (the infinite loop) and perform subsequent calls to skeleton generator script using Docker `exec` command with the created container.
This commit is contained in:
Alexander Koshevoy
2018-08-30 15:39:55 +03:00
parent 8a9df17754
commit 18ed62825c
2 changed files with 29 additions and 9 deletions

10
python/helpers/idle.py Normal file
View File

@@ -0,0 +1,10 @@
import sys
import time
if __name__ == '__main__':
if len(sys.argv) > 0:
started_message = sys.argv[1]
print(started_message)
while True:
time.sleep(100)

View File

@@ -149,6 +149,24 @@ public class PySkeletonGenerator {
String binaryPath, String extraSyspath)
throws InvalidSdkException {
final String parent_dir = new File(binaryPath).getParent();
List<String> commandLine = buildSkeletonGeneratorCommandLine(modname, modfilename, assemblyRefs, binaryPath, extraSyspath);
final Map<String, String> extraEnv = PythonSdkType.getVirtualEnvExtraEnv(binaryPath);
final Map<String, String> env = new HashMap<>(extraEnv != null ? PySdkUtil.mergeEnvVariables(myEnv, extraEnv) : myEnv);
if (myPrebuilt) {
env.put("IS_PREGENERATED_SKELETONS", "1");
}
return getProcessOutput(parent_dir, ArrayUtil.toStringArray(commandLine), env, MINUTE * 10);
}
@NotNull
protected final List<String> buildSkeletonGeneratorCommandLine(@NotNull String modname,
@Nullable String modfilename,
@Nullable List<String> assemblyRefs,
@NotNull String binaryPath,
@Nullable String extraSyspath) {
List<String> commandLine = new ArrayList<>();
commandLine.add(binaryPath);
commandLine.add(PythonHelpersLocator.getHelperPath(GENERATOR3));
@@ -169,15 +187,7 @@ public class PySkeletonGenerator {
if (modfilename != null) {
commandLine.add(modfilename);
}
final Map<String, String> extraEnv = PythonSdkType.getVirtualEnvExtraEnv(binaryPath);
final Map<String, String> env = new HashMap<>(extraEnv != null ? PySdkUtil.mergeEnvVariables(myEnv, extraEnv) : myEnv);
if (myPrebuilt) {
env.put("IS_PREGENERATED_SKELETONS", "1");
}
return getProcessOutput(parent_dir, ArrayUtil.toStringArray(commandLine), env, MINUTE * 10);
return commandLine;
}
protected ProcessOutput getProcessOutput(String homePath, String[] commandLine, Map<String, String> extraEnv,