def create(cls: Type[U], env: Mapping[str, str], use_serverless_ide: bool) -> Iterator[U]: args = ["--enhanced-hover"] if use_serverless_ide: args.append("--serverless-ide") proc = subprocess.Popen( [hh_client, "lsp"] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, # so hh_client inherits (=> writes to) our own stderr env=env, ) # Use the unbuffered versions of these streams, as the buffered versions # of these streams sometimes cause deadlocks when accessed from multiple # threads. stdin = proc.stdin.detach() # pyre-ignore stdout = proc.stdout.detach() try: reader = JsonRpcStreamReader(stdout) writer = JsonRpcStreamWriter(stdin) yield cls(proc, reader, writer) finally: stdin.close() stdout.close()
def create(cls, env): proc = subprocess.Popen([hh_client, 'lsp', '--enhanced-hover'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) try: reader = JsonRpcStreamReader(proc.stdout) writer = JsonRpcStreamWriter(proc.stdin) yield cls(proc, reader, writer) finally: proc.stdin.close() proc.stdout.close() proc.stderr.close()
def create(cls: Type[U], env: Mapping[str, str]) -> Iterator[U]: proc = subprocess.Popen( [hh_client, "lsp", "--enhanced-hover"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, ) try: reader = JsonRpcStreamReader(proc.stdout) writer = JsonRpcStreamWriter(proc.stdin) yield cls(proc, reader, writer) finally: proc.stdin.close() proc.stdout.close() proc.stderr.close()
def create(cls): # yes shell = True is generally a bad idea, but # in this case we want to pick up your environment entirely because # hack depends heavily on it to work proc = subprocess.Popen('hh_client lsp', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) reader = JsonRpcStreamReader(proc.stdout) writer = JsonRpcStreamWriter(proc.stdin) yield cls(proc, reader, writer) proc.stdin.close() proc.stdout.close() proc.stderr.close()
def create(cls: Type[U], env: Mapping[str, str], use_serverless_ide: bool) -> Iterator[U]: args = ["--enhanced-hover"] if use_serverless_ide: args.append("--serverless-ide") proc = subprocess.Popen( [hh_client, "lsp"] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, ) try: stdout: BinaryIO = proc.stdout # pyre-ignore stdin: BinaryIO = proc.stdin # pyre-ignore reader = JsonRpcStreamReader(stdout) writer = JsonRpcStreamWriter(stdin) yield cls(proc, reader, writer) finally: proc.stdin.close() proc.stdout.close() proc.stderr.close()