Comments (3)
Hey @Tiadem, welcome! As you have observed, timeout
doesn't work with sleep
. That's because it's a blocking function that blocks the whole process. In fact, timeout
doesn't cancel any operation either, it's just a way to timeout waiting for a particular promise to resolve.
Try adding another repeat
timer that prints some dots periodically and observe the difference with using sleep vs. delay.
from amp.
Hey @kelunik thanks for support, you guys are doing great job for PHP 😄 . Perhaps i have to dive more into understanding those async, concurrency concepts.At the beginning i assumed that timeout function starts counting from Loop's defer function call till resolve function call. If that process will exceed timeout then exception will be thrown immediately and stops further promise resolving as it's catched. But now i suppose that regular sleep function stops everything including time counting between defer call and resolve call. Is there any example from standard PHP operations that works with timeout or just those Loop delay and repeat functions?
from amp.
@Tiadem Thanks! sleep
doesn't stop the time counting, but it simply blocks the defer callback from executing or rather the event loop checking whether it should execute anything else. Standard PHP functions aren't compatible with the event loop without special care, e.g. streams need to be set to non-blocking mode. That's why we've built to many packages around I/O implementing things in a non-blocking and compatible way.
from amp.
Related Issues (20)
- Getting access to child process data on SIGCHLD in Loop::onSignal. HOT 16
- Confusing diagram in README HOT 6
- Return self in Future::ignore HOT 1
- UnhandledFutureError is hard to debug HOT 2
- Migration guide for combinator functions HOT 5
- FiberError: Cannot switch fibers in current execution context on Laravel HOT 4
- 32 bit PHP: Return value of Amp\Loop\NativeDriver::now() must be of the type int, float returned HOT 5
- Functions should require callable instead of closures HOT 10
- Any way to create or get a context for coroutine. HOT 5
- Version confusion HOT 8
- Shouldn't Future::finally() pass the future data to the provided callback? HOT 7
- Event loop terminated without resuming the current suspension (the cause is either a fiber deadlock, or an incorrectly unreferenced/canceled watcher) HOT 3
- Future combinators HOT 8
- When to not to use `async`?
- Comparison with ReactPHP HOT 8
- The docs not up to date? HOT 3
- Where is this `any()` function?
- Interception of pause / resume future HOT 2
- Add Payload::readEntireBody? HOT 3
- Symfony Messenger Integration HOT 4
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 amp.