Skip to content

Commit 19b2445

Browse files
committed
Get rid of intermediate ack; update docstring
1 parent a068037 commit 19b2445

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

mypy/build.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,6 @@ def wait_for_done_workers(
12341234
assert data.result is not None
12351235
results.update(data.result)
12361236
if data.is_interface:
1237-
send(self.workers[idx].conn, AckMessage())
12381237
done_sccs.append(self.scc_by_id[scc_id])
12391238
self.submit_to_workers(graph) # advance after some workers are free.
12401239
return (

mypy/build_worker/worker.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
* Read (pickled) build options from command line.
66
* Populate status file with pid and socket address.
77
* Receive build sources from coordinator.
8-
* Load graph using the sources, and send ack to coordinator.
8+
* Initialize build manager with the sources, and send ack to coordinator.
9+
* Receive build graph from coordinator, and ack it.
910
* Receive SCC structure from coordinator, and ack it.
10-
* Receive an SCC id from coordinator, process it, and send back the results.
11-
* Each SCC is processed in two phases: interface then implementation, with an ack in
12-
between. (It is not 100% clear why the ack is needed, but deadlocks happen without it)
13-
* When prompted by coordinator (with a scc_id=None message), cleanup and shutdown.
11+
* In a loop:
12+
- Receive an SCC id from coordinator, and start processing it.
13+
- SCC is processed in two phases: interface and implementation, send a response after each.
14+
- When prompted by coordinator (with a scc_id=None message), cleanup and shutdown.
1415
"""
1516

1617
from __future__ import annotations
@@ -30,7 +31,6 @@
3031

3132
from mypy import util
3233
from mypy.build import (
33-
ACK_MESSAGE,
3434
GRAPH_MESSAGE,
3535
SCC,
3636
SCC_REQUEST_MESSAGE,
@@ -201,9 +201,6 @@ def serve(server: IPCServer, ctx: ServerContext) -> None:
201201
mod_results[id] = mod_result
202202
meta_files.append(meta_file)
203203
send(server, SccResponseMessage(scc_id=scc_id, is_interface=True, result=mod_results))
204-
# Only proceed with the implementations if there are no blockers so far.
205-
if should_shutdown(receive(server), ACK_MESSAGE):
206-
break
207204
try:
208205
result = process_stale_scc_implementation(graph, stale, manager, meta_files)
209206
# Both phases write cache, so we should commit here as well.

mypy/ipc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ def ready_to_read(conns: list[IPCClient], timeout: float | None = None) -> list[
366366
367367
Return index of each readable connection in the original list.
368368
"""
369+
unread_messages = [i for i, conn in enumerate(conns) if conn.buffer]
370+
if unread_messages:
371+
# If we already have unread messages in the buffer, return those first.
372+
return unread_messages
369373
if sys.platform == "win32":
370374
# Windows doesn't support select() on named pipes. Instead, start an overlapped
371375
# ReadFile on each pipe (which internally creates an event via CreateEventW),

0 commit comments

Comments
 (0)