Enhance concurrency handling with improved ticket acquisition logic and logging

This commit is contained in:
ImBenji
2025-11-23 19:21:13 +00:00
parent f5a23fa5c4
commit 809d79cfc8
3 changed files with 76 additions and 46 deletions

View File

@@ -22,8 +22,15 @@ void main() async {
final file = File('example.bin');
if (await file.exists()) {
final raf = await file.open(mode: FileMode.read);
// Check file size first
int fileSize = await file.length();
if (fileSize < 48) {
print('Error: example.bin too small ($fileSize bytes) - Refresh #$refreshCount');
await Future.delayed(Duration(seconds: 1));
continue;
}
final raf = await file.open(mode: FileMode.read);
try {
final header = SweepstoreHeader(raf);
@@ -71,7 +78,10 @@ void main() async {
// updat previous master heartbeat
previousMasterHeartbeat = concurrency.masterHeartbeat;
print('--- Refreshing in 1 seconds ---');
print('--- Refreshing in 1 second ---');
} catch (e) {
print('Error reading file: $e');
print('File may be in inconsistent state, retrying...');
} finally {
await raf.close();
}
@@ -79,6 +89,6 @@ void main() async {
print('Error: example.bin not found - Refresh #$refreshCount');
}
await Future.delayed(Duration(milliseconds: 1));
await Future.delayed(Duration(seconds: 1));
}
}