Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port bin #6126

Merged
merged 11 commits into from
Jul 25, 2018
1 change: 1 addition & 0 deletions src/python/pants/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
python_library(
dependencies=[
'3rdparty/python/twitter/commons:twitter.common.collections',
'3rdparty/python:future',
'3rdparty/python:setproctitle',
'src/python/pants/backend/jvm/tasks:nailgun_task',
'src/python/pants/base:build_environment',
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/bin/daemon_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import termios
import time
from builtins import bytes, str, zip
from contextlib import contextmanager

from setproctitle import setproctitle as set_process_title
Expand Down Expand Up @@ -285,7 +286,7 @@ def post_fork_child(self):

# Broadcast our process group ID (in PID form - i.e. negated) to the remote client so
# they can send signals (e.g. SIGINT) to all processes in the runners process group.
NailgunProtocol.send_pid(self._socket, bytes(os.getpgrp() * -1))
NailgunProtocol.send_pid(self._socket, bytes(str(os.getpgrp() * -1), 'ascii'))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwlzn and I discussed this in the Python3 slack channel. We're first calling str() to cast the int to a str, then bytes() because Nailgun is expecting bytes with its IO


# Invoke a Pants run with stdio redirected and a proxied environment.
with self.nailgunned_stdio(self._socket, self._env) as finalizer,\
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/bin/goal_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import logging
import sys
from builtins import object

from pants.base.cmd_line_spec_parser import CmdLineSpecParser
from pants.base.workunit import WorkUnit, WorkUnitLabel
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/bin/local_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
from builtins import object

from pants.base.build_environment import get_buildroot
from pants.bin.goal_runner import GoalRunner
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/bin/pants_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import locale
import os
import warnings
from builtins import object


class PantsLoader(object):
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/bin/pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import os
import sys
from builtins import object

from pants.bin.remote_pants_runner import RemotePantsRunner
from pants.option.options_bootstrapper import OptionsBootstrapper
Expand Down
8 changes: 6 additions & 2 deletions src/python/pants/bin/remote_pants_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import signal
import sys
import time
from builtins import object, str
from contextlib import contextmanager

from future.utils import raise_with_traceback

from pants.console.stty_utils import STTYSettings
from pants.java.nailgun_client import NailgunClient
from pants.java.nailgun_protocol import NailgunProtocol
Expand Down Expand Up @@ -122,9 +125,10 @@ def _run_pants_with_retry(self, port, retries=3):
# Ensure a newline.
logger.fatal('')
logger.fatal('lost active connection to pantsd!')
raise self.Terminated, (
raise_with_traceback(
self.Terminated,
'abruptly lost active connection to pantsd runner: {!r}'.format(e)
), e.traceback
)

def _connect_and_execute(self, port):
# Merge the nailgun TTY capability environment variables with the passed environment dict.
Expand Down