|
1 | | -import base64 |
2 | 1 | import logging |
3 | 2 | import math |
4 | 3 | import pickle |
|
9 | 8 | from collections import defaultdict |
10 | 9 | from concurrent.futures import Future |
11 | 10 | from dataclasses import dataclass |
12 | | -from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union |
| 11 | +from typing import IO, Callable, Dict, List, Optional, Sequence, Tuple, Union |
13 | 12 |
|
14 | 13 | import typeguard |
15 | 14 |
|
@@ -543,18 +542,22 @@ def _start_local_interchange_process(self) -> None: |
543 | 542 | "cert_dir": self.cert_dir, |
544 | 543 | } |
545 | 544 |
|
546 | | - encoded = base64.b64encode(pickle.dumps(interchange_config)) |
| 545 | + config_pickle = pickle.dumps(interchange_config) |
547 | 546 |
|
548 | | - cmd: List[bytes] = [b"interchange.py", |
549 | | - encoded |
550 | | - ] |
551 | | - self.interchange_proc = subprocess.Popen(cmd) |
| 547 | + self.interchange_proc = subprocess.Popen(b"interchange.py", stdin=subprocess.PIPE) |
| 548 | + stdin = self.interchange_proc.stdin |
| 549 | + assert stdin is not None, "Popen should have created an IO object (vs default None) because of PIPE mode" |
552 | 550 |
|
| 551 | + logger.debug("Popened interchange process. Writing config object") |
| 552 | + stdin.write(config_pickle) |
| 553 | + stdin.flush() |
| 554 | + logger.debug("Sent config object. Requesting worker ports") |
553 | 555 | try: |
554 | 556 | (self.worker_task_port, self.worker_result_port) = self.command_client.run("WORKER_PORTS", timeout_s=120) |
555 | 557 | except CommandClientTimeoutError: |
556 | | - logger.error("Interchange has not completed initialization in 120s. Aborting") |
| 558 | + logger.error("Interchange has not completed initialization. Aborting") |
557 | 559 | raise Exception("Interchange failed to start") |
| 560 | + logger.debug("Got worker ports") |
558 | 561 |
|
559 | 562 | def _start_queue_management_thread(self): |
560 | 563 | """Method to start the management thread as a daemon. |
|
0 commit comments