Reads from STDIN and places a message with that data onto the input_queue.
(self)
| 734 | return chunk |
| 735 | |
| 736 | def _input_thread(self): |
| 737 | """ |
| 738 | Reads from STDIN and places a message |
| 739 | with that data onto the input_queue. |
| 740 | """ |
| 741 | |
| 742 | message = { |
| 743 | 'type': 'ATTACH_CONTAINER_INPUT', |
| 744 | 'attach_container_input': { |
| 745 | 'type': 'PROCESS_IO', |
| 746 | 'process_io': { |
| 747 | 'type': 'DATA', |
| 748 | 'data': { |
| 749 | 'type': 'STDIN', |
| 750 | 'data': ''}}}} |
| 751 | |
| 752 | for chunk in iter(partial(os.read, sys.stdin.fileno(), 1024), b''): |
| 753 | chunk = self._detect_exit_sequence(chunk) |
| 754 | if self.exit_sequence_detected: |
| 755 | break |
| 756 | |
| 757 | message[ |
| 758 | 'attach_container_input'][ |
| 759 | 'process_io'][ |
| 760 | 'data'][ |
| 761 | 'data'] = base64.b64encode(chunk).decode('utf-8') |
| 762 | |
| 763 | self.input_queue.put(self.encoder.encode(message)) |
| 764 | |
| 765 | # Push an empty string to indicate EOF to the server and push |
| 766 | # 'None' to signal that we are done processing input. |
| 767 | message['attach_container_input']['process_io']['data']['data'] = '' |
| 768 | self.input_queue.put(self.encoder.encode(message)) |
| 769 | self.input_queue.put(None) |
| 770 | |
| 771 | def _output_thread(self): |
| 772 | """ |
nothing calls this directly
no test coverage detected