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

Fix for output buffering issue #354

Closed
wants to merge 2 commits into from
Closed

Conversation

shandak
Copy link

@shandak shandak commented Jun 30, 2021

When several 'async' functions contain something like

ob_start();
....
Do some async stuff, like database select and 'echo' result
...
echo 'something';
$content = ob_get_contents();
ob_end_clean();

It's getting a mess with the result in $content

@kelunik
Copy link
Member

kelunik commented Jul 7, 2021

@shandak Output buffering is global, so concurrent output is expected to be "a mess". A better solution would be to write to some kind of OutputStream IMO instead of using echo.

@shandak
Copy link
Author

shandak commented Jul 8, 2021

@shandak Output buffering is global, so concurrent output is expected to be "a mess". A better solution would be to write to some kind of OutputStream IMO instead of using echo.

Agreed, I would not recommend using global output buffering too, but the goal here is to start using 'fibers' with already developed solutions without dramatic changes. For instance, in my case, it sounds almost impossible because ob_start is everywhere.

Maybe as another solution, it would be better to add event triggers around Fiber::suspend so everybody can add some custom behaviour for a specific purpose?

@kelunik
Copy link
Member

kelunik commented Jul 8, 2021

Supporting custom hooks for Fiber::suspend is likely a good idea, but we need to ensure it's lightweight enough, as it will happen quite frequently.

@trowski trowski deleted the branch amphp:v3 October 14, 2021 22:58
@trowski trowski closed this Oct 14, 2021
@trowski
Copy link
Member

trowski commented Oct 16, 2021

@shandak This got closed unintentionally without comment when I was renaming some branches. Apparently the v3 branch was temporarily deleted.

As amphp v3 will be using Revolt, I've opened a PR there that would enable the usage you were looking for here: revoltphp/event-loop#2

@shandak
Copy link
Author

shandak commented Oct 18, 2021

That's great news, thank you a lot!

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

Successfully merging this pull request may close these issues.

3 participants