Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Could not write to storage" for FileStorage #21

Open
maximzasorin opened this issue May 29, 2018 · 3 comments
Open

"Could not write to storage" for FileStorage #21

maximzasorin opened this issue May 29, 2018 · 3 comments

Comments

@maximzasorin
Copy link

When I use next code for bootstrap token bucket:

use bandwidthThrottle\tokenBucket\Rate;
use bandwidthThrottle\tokenBucket\TokenBucket;
use bandwidthThrottle\tokenBucket\storage\FileStorage;

$storage = new FileStorage(__DIR__ . "/api.bucket");
$rate = new Rate(10, Rate::SECOND);
$bucket = new TokenBucket(10, $rate, $storage);
$bucket->bootstrap(10);

On Linux and macOS all works well, but in Windows I get an error:

Could not write to storage.

Maybe it's because the file opens twice, first, in FileStorage::__construct, then file locked by flock and then file opens in FileStorage::bootstrap method.

@tepeumut
Copy link

tepeumut commented Aug 8, 2019

Did you remove $bucket->bootstrap(10); ?

@emmanuelmahove
Copy link

Had the same problem on Windows but it went away when I commented out the second file open in the bootstrap method.

$this->open(); // remove() could have deleted the file.

@simillo01
Copy link

For some reason with PHP 8.1.6 and that commit on my windows machine is not working, if i comment that line it works. Someone know why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants