Enhance concurrency handling with improved ticket acquisition logic and logging
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user