Bad state: withResource() may not be called on a closed Pool.
xvrh opened this issue · comments
Xavier H. commented
import 'dart:async';
import 'package:pool/pool.dart';
main() async {
Pool pool = new Pool(3);
for (int i = 0; i < 4; i++) {
pool.withResource(() {
print(i);
});
}
await pool.close();
}
With the version 1.2.1 of pool it prints "0, 1, 2, 3"
With version 1.2.2, it fails with error
Unhandled exception:
Bad state: withResource() may not be called on a closed Pool.
#0 Pool.withResource.<withResource_async_body> (package:pool/pool.dart:111:7)
#1 Future.Future.microtask.<anonymous closure> (dart:async/future.dart:144)
#2 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#3 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#4 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)