hi all, small dart tool here, it summarises temperature CSVs and I spawn one isolate per file so the big ones don't wait for each other. i run it in WSL like this:
dart run bin/summarize.dart data/north.csv data/south.csv -v
with -v i see the two "spawned worker" lines and then two "got ... rows" lines, and the row counts are right. so the workers clearly do their work. but then nothing. no table, no prompt back, i have to Ctrl+C.
first i thought the readAsLinesSync in the worker was blocking something, then i wrapped the worker body in try/catch, but nothing is thrown and nothing changes.
what confuses me is that i remember the loop in main ending by itself once all the spawned isolates were finished. that's why i'm using await for and not counting results. this is the main part:
final port = ReceivePort();
for (final p in paths) {
await Isolate.spawn(summarizeFile, WorkOrder(p, port.sendPort));
log.debug('spawned worker for $p');
}
final results = <FileSummary>[];
await for (final msg in port) {
final s = msg as FileSummary;
results.add(s);
log.info('got ${s.path}: ${s.count} rows');
}
results.sort((a, b) => a.path.compareTo(b.path));
printTable(results);
worker just does order.replyTo.send(FileSummary(...)) at the end and returns. recent Dart 3.x. did something change about when that loop ends? i don't want to rewrite the collecting part before i understand this.