diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-10 20:18:58 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-10 20:18:58 +0900 |
commit | 84422bb168c483ccaba9ac12c71b36a74d4f91b5 (patch) | |
tree | a37ab4c4fcd4b2a6c24721b34f62d0c6271ec4aa | |
parent | c09e744684b8bcf834c02b1e8386e6ff2b59f542 (diff) | |
download | buildstream-84422bb168c483ccaba9ac12c71b36a74d4f91b5.tar.gz |
Testing
-rw-r--r-- | buildstream/_artifactcache/pushreceive.py | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py index 487b60d0d..4fd3265f1 100644 --- a/buildstream/_artifactcache/pushreceive.py +++ b/buildstream/_artifactcache/pushreceive.py @@ -315,7 +315,7 @@ class OSTreePusher(object): self.refs[branch] = rev # Start ssh - ssh_cmd = ['ssh', '-tt'] + ssh_cmd = ['ssh'] if self.remote_user: ssh_cmd += ['-l', self.remote_user] if self.remote_port: @@ -329,7 +329,8 @@ class OSTreePusher(object): logging.info('Executing {}'.format(' '.join(ssh_cmd))) self.ssh = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=self.output) + stderr=self.output, + start_new_session=True) self.writer = PushMessageWriter(self.ssh.stdin) self.reader = PushMessageReader(self.ssh.stdout) @@ -477,20 +478,14 @@ class OSTreeReceiver(object): return 0 def run(self): - - def terminate_receive(): + try: + exit_code = self.do_run() self.close() - os._exit(1) - - with _signals.terminator(terminate_receive): - try: - exit_code = self.do_run() - self.close() - return exit_code - except PushException: - # Ensure we cleanup files if there was an error - self.close() - raise + return exit_code + except PushException, BrokenPipeError: + # Ensure we cleanup files if there was an error + self.close() + raise def do_run(self): # Send info immediately @@ -570,8 +565,7 @@ def push(repo, remote, branch, output): pusher = OSTreePusher(repo, remote, [branch], True, False, output=output) def terminate_push(): - if pusher.ssh: - pusher.ssh.terminate() + pusher.close() with _signals.terminator(terminate_push): try: @@ -604,12 +598,4 @@ def receive_main(): level=loglevel, stream=sys.stderr) receiver = OSTreeReceiver(args.repo) - - # Terminate on SIGHUP - def sighup_handler(signal, frame): - receiver.close() - os._exit(1) - - signal.signal(signal.SIGHUP, sighup_handler) - return receiver.run() |