Joel Berger

Well, you can. So, there are several ways around this.

First of all you can do sort of, well, that is the easiest way and particularly if you are using one of the.. So, Mojolicious project has spawned a couple of sort of spin-off projects that wrap databases in a more asynchronous way. The primary one is Postgres.

Our project founder Sebastian Riedel has really taken on to Postgres lately and actually one of other core members Abhijit Menon-Sen, I hope I am saying that right, is Crab on IRC, that is a lot easier to say, is also on the Postgres development team. So, that is a really cool crossover we have there.

When we have questions about PostgreS, we can just call over Crab and say "Hey, this thing is confusing us" and he can help us out but we have a wrapper. It is still just using DBI and DBD::PG but it provides you a non-blocking interface and when you do that, you have got this query that is going to take 5 minutes to run and assuming you have set up all your timeouts correctly, you can keep serving other clients while that query is running.

And when the query is completed and it starts sending you data back, then you can respond to that client. That is the easiest way to do it. If you cannot do that for some reason and if you are not using a database that has a reactive or a non-blocking client, then you can do several different sorts of forking where you fork after getting the request, do your computation in some other process and then you pipe the results back to your original server.

And we have plug-ins for that too. I have written one called Mojolicious::Plugin::ForkCall It is actually Mojo::IOLoop::ForkCall too, but do not worry about that.

And Jan Henning Thorsen, another of the Mojo core developers has one called Mojo::IOLoop::ReadWriteFork. You can actually interact with your forked process. You can send it data over a pipe and it thinks that it is standard input and you can send data back over it. So, that is where we are doing really long running things where you want to monitor some process or whatever. So, there are plenty of options for what we call unblocking code and they all work fairly well with a slight asterisk around Windows of course because forking and piping and things do not work so well on Windows.

Actually with the new Windows subsystem for Linux which is the real name, people have been calling Bash on windows, it is really called WSL or Windows Subsystem for Linux is we have actually had some fairly good reports of Mojolicious. The corner cases that Windows did not work as well are working quite nicely on Windows Subsystem for Linux. So, we are very excited about that.