fancy-photographer-78161
06/20/2023, 10:02 AMgorgeous-winter-99296
06/20/2023, 10:21 AMPANTS_CONCURRENT=true
. See caveats here though: https://www.pantsbuild.org/docs/reference-global#concurrent
2. Yes, but depends on the target. On some targets you can set restartable=True
in your BUILD file and it should work: https://www.pantsbuild.org/docs/reference-python_sources#coderestartablecode. I tend to to use a method which combines pants --loop package ...
with another subprocess to pick up the produced artifact and runs it outside pants. It depends a bit on the semantics.gorgeous-winter-99296
06/20/2023, 10:29 AMimport http.server
import os
import socketserver
import subprocess
import threading
from functools import partial
def pants(*args):
return subprocess.check_output(
[
"pants",
*args,
],
env=os.environ
| {
"PANTS_CONCURRENT": "true",
},
)
class Server(socketserver.TCPServer):
allow_reuse_address = True
def build_docs():
pants("--loop", "package", "docs:docs")
def main():
threading.Thread(target=build_docs).start()
Handler = partial(http.server.SimpleHTTPRequestHandler, directory="dist/docs/book/")
server = Server(("", 8000), Handler)
server.allow_reuse_address = True
with server as httpd:
httpd.serve_forever()
main()
This technically isn't parallel, it's nested - we use pants run scripts/docs.py
(through the alias pants serve-docs
). The ones where we do use parallel work are much longer unfortunately. 😛