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

Not whole file is read if use the eio adapter #73

Open
Logioniz opened this issue Dec 12, 2019 · 0 comments
Open

Not whole file is read if use the eio adapter #73

Logioniz opened this issue Dec 12, 2019 · 0 comments
Assignees

Comments

@Logioniz
Copy link

Steps to reproduce behavior

1. create file

php -r 'foreach(range(0, 1000000) as $i) { print $i . PHP_EOL; }' > static/test.txt

2. create script

<?php

use \React\Promise\Deferred;

$loader = require __DIR__ . '/vendor/autoload.php';

#$loop = React\EventLoop\Factory::create();
$loop = new React\EventLoop\ExtEvLoop();

$filesystem = \React\Filesystem\Filesystem::create($loop);
    $file = $filesystem->file('static/test.txt');
    $file->exists()
        ->then(function () use ($file) {
            return $file->open('r');
        })
        ->then(function ($stream) use ($loop) {
            $d = new Deferred();
            $stream->on('data', function ($data) {
                print $data;
            });
            $stream->on('end', function ($data) use ($stream, $d) {
                $stream->close();
                $d->resolve('finish');
            });

            return $d->promise();
        })
        ->then(function () use ($loop) {
            $loop->stop();
        })
        ->otherwise(function ($e) {
            var_dump($e);
        });
$loop->run();

3. run

php7.3 3.php
0
1
2
3
...
375148
375149
3751root@7cf1e7fada2c:/app/adv# 

if you change the adapter to child process then everything works well

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

2 participants