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

Multiple event loop #122

Closed
sm2017 opened this issue Nov 30, 2017 · 5 comments
Closed

Multiple event loop #122

sm2017 opened this issue Nov 30, 2017 · 5 comments
Labels

Comments

@sm2017
Copy link

sm2017 commented Nov 30, 2017

How can I have multiple event loop in a script??Without blocking each other . I want to use select and event

@kelunik
Copy link
Contributor

kelunik commented Nov 30, 2017

You can't, unless one calls the other in a busy waiting manner. Why do you want two?

@sm2017
Copy link
Author

sm2017 commented Nov 30, 2017

The reason is #121

I want have event as main loop and select for pg_socket

@WyriHaximus
Copy link
Member

@sm2017 you can't without the loops blocking each other, have you tried any of the other event loops?

@mbonneau
Copy link

@sm2017 - If you are just looking for an async way to use Postgres - take a look at https://github.com/voryx/PgAsync which is based on react and rxphp.

This library is a 100% native PHP implementation.

@clue clue added the question label Dec 3, 2017
@clue
Copy link
Member

clue commented Dec 3, 2017

The short version is: You can't.

The longer version is: You shouldn't. There are a number of work-arounds which basically resolve to polling one loop from the other one as @kelunik suggested or you may spawn/fork multiple processes and use some kind of IPC protocol etc.

The linked ticket #121 is a very specific issue with ext-event, so I would still suggest reporting this upstream and validating why this causes a SEGFAULT to begin with. As an alternative, I would suggest looking into using one of the alternative loop implementations as @WyriHaximus suggested. Also, @mbonneau made a very good point about using another database layer to avoid this issue in the first place.

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this 👍

@clue clue closed this as completed Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants