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

Async processing for some events #26

Open
fat-crocodile opened this issue May 31, 2018 · 0 comments
Open

Async processing for some events #26

fat-crocodile opened this issue May 31, 2018 · 0 comments

Comments

@fat-crocodile
Copy link

fat-crocodile commented May 31, 2018

Hi!
Good job, and there is a lot of wit in it. The two-thread solution is great.

But I found two types of events, that should be processed in recv-thread, not in an event one.

  1. Inspector.targetCrashed -- tab crash. Problem is: after this event there will be no answers for waiting calls (not even with errors -- nothing! on chromium 66.0.3359.181 at least), so if you just put it in the event queue, you may not get it after all. Your still working event handlers may hang up, waiting for an answer. So after Inspector.targetCrashed have arrived, you should call stop() immediately in the _recv_loop function.

  2. Calling methods in not-main targets (chrome terminology for threads). You call it through method Target.sendMessageToTarget and get an answer through event Target.receivedMessageFromTarget. The problem is: if you are in an event-handler and you operate in one thread, you can not just wait for an answer -- it will never come. It will come in recv, and will be enqueued, but would not be processed until your current handler is finished -- it is a deadlock.

There is a workaround of cause. You can start a separate thread for every event handler, that call any API methods. But it is an ugly solution.

I suggest something like that:

crashed_tab.txt

I actually use it now, and it seems to work ok.
Maybe you can adapt this idea and use it in your library?

P.S. For clarity. The "idea" here is just some possibility to install recv-time handlers for messages. All other just implementation details and example.

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

No branches or pull requests

2 participants