Comments (7)
I'm not sure I follow what you're doing, can you provide a gist to reproduce this?
In case you're calling tick()
will the loop is running, this is probably where the problem comes from. This should not be done, ever.
from event-loop.
@clue Please check this library:
https://github.com/WyriHaximus/reactphp-psr7-stream-converter/blob/master/src/ReactToPSR7Stream.php
Here tick() is called if on read there is no data. If I understand correctly, this is for loop not to block.
I use futureTick to queue read/write pipeline, eg:
public function tick()
{
while (true) {
$data = $this->input->read(self::BUFFER);
if ('' === $data) {
break;
}
// TODO: limit write rate
$this->output->write($data);
}
if (!$this->input->eof()) {
$this->queueTick();
return;
}
$this->input->close();
$this->output->close();
call_user_func($this->result);
}
protected function queueTick()
{
$this->loop->futureTick([$this, 'tick']);
}
Is this a correct way to implement PSR7->PSR7 pipeline?
from event-loop.
Another example:
https://github.com/WyriHaximus/ReactGuzzle/blob/master/src/HttpClientAdapter.php
What if we make a call inside a loop?
from event-loop.
Let's ping @WyriHaximus and let's see what he has to add 👍
from event-loop.
@nick4fake it's a horrible hack that I would not recomend 😞 , heck I strongly discourage of doing it when there are alternatives. It 'works' but only in most circumstances. That one in particular was made to provide a fully working PSR-7
stream. @clue made a much better way of doing that here. Another place I use it is here, but there I'm doing it because Guzzle uses some funky queue that I have to keep running in order for the adapter to work 😞 .
from event-loop.
@WyriHaximus thanks for giving some insight! What do you suggest we should do here? Is this something worth fixing or should we look into avoiding this altogether (is this even reasonable?)?
from event-loop.
I believe this has been superseded now that #72 is in and the tick()
method has been removed 👍
I'm closing this for now, please feel free to come back with more details if this problem persists and we can reopen this 👍
from event-loop.
Related Issues (20)
- SIGTSTP not working HOT 4
- Is it possible to export the code of the main loop as a function, so that there is no need to write a callback function. HOT 1
- Manual "tick" execution HOT 11
- Implementations of ::run() use signals->isEmpty() which prevents exiting HOT 3
- PHP8: Uncaught ValueError: No stream arrays wered pased in StreamSelectLoop:: HOT 8
- Loop signals in PHP8 HOT 4
- Infinite recursion bug with timers HOT 6
- How to update the time Interval dynamically? HOT 2
- Periodic timer jumping from one value to another directly. HOT 2
- Experiencing issue with addPeriodicTimer seemingly just stopping randomly HOT 5
- periodic timer with the interval of zero HOT 4
- Rollback the deprecation of the Factory::create method HOT 7
- Question: error missing from register_shutdown_function when using implicit loop vs explicit loop. HOT 2
- [Help] Writing PHPUnit tests - Laravel HOT 3
- Any way to "reset" the loop? HOT 4
- Deprecated: Implicit conversion from float 4995090.007781982 to int loses precision in vendor\react\event-loop\React\EventLoop\StreamSelectLoop.php on line 137 HOT 3
- Watchdog timers HOT 3
- Have a look here HOT 3
- How to aggregate data processed in parallel with pcntl HOT 4
- Roadmap to reactphp/event-loop v3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from event-loop.