Replies: 4 comments 10 replies
-
The SQLite API is synchronous, because it's just opening a file. It does not have the ability to execute a non-blocking query. However, you can use the normal mechanisms of https://metacpan.org/pod/Mojo::IOLoop#subprocess or https://metacpan.org/pod/IO::Async::Function to avoid blocking your main loop with excessively slow queries. Just keep in mind this is less useful with SQLite as it is still just a file and cannot handle simultaneous queries as well as Postgres, especially without WAL mode. |
Beta Was this translation helpful? Give feedback.
-
It should be possible via Future::AsyncAwait, depending on whether it is designed to allow usage of the Mojolicious loop. I haven't investigated it yet. |
Beta Was this translation helpful? Give feedback.
-
|
For async/await stuff you don't need to search the web for blog posts, we have examples right in the documentation: https://docs.mojolicious.org/Mojolicious/Guides/Cookbook#async-await |
Beta Was this translation helpful? Give feedback.
-
All the things PAGI promises we've already been doing in Mojolicious for many years, so there isn't really any advantage for us. To be honest, until this discussion thread i didn't know the spec existed in the first place. Nobody told me. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What does Mojolicious think about PAGI?
I am completely new to async / await stuff in Perl, and wondering if this new tech is something I can use with Mojolicious?
I see you did stuff based on https://metacpan.org/pod/Future::AsyncAwait
via the blog https://mojolicious.io/ - with posts in both 2021 and 2019 mentioning it.
So will it be possible to write a non-blocking webapp in Mojolicious, and use it with something like PAGI, in the same way I do with PSGI today for a blocking webapp?
Also - I have begun using Mojo::SQLite for a lot of small project webapps, and wonder if a non-blocking approach to databases is possible with it, or only with Mojo::Pg ...?
There's this strange line in the Mojo::SQLite::Database documentation that keeps cropping up: "For API compatibility with Mojo::Pg; the query is still executed in a blocking manner." This doesn't appear in Mojo::Pg::Database documentation.
PAGI is still in beta, and welcoming feedback. Here are a collection of links:
John Napiorkowski's blogging:
Asking for feedback here...
https://dev.to/jjn1056/pagi-asgi-for-perl-or-the-spiritual-successor-to-plack-3kb9
Getting philosophical over how some of it was vibe coded here:
https://dev.to/jjn1056/the-joy-of-code-in-the-age-of-vibe-engineering-49j2
And performance testing a hello world server here...
https://dev.to/jjn1056/pagiserver-performance-and-hardening-l8d
John aims to have a beta of PAGI on CPAN soon:
https://metacpan.org/pod/PAGI
...which will not be production ready,
and is more for testing out, and getting feedback on.
It is on Github to play about with:
https://github.com/jjn1056/pagi
There was also a Perl Advent Calendar entry on the subject of PAGI:
https://perladvent.org/2025/2025-12-10.html
He is currently welcoming feedback on his first attempt at a tutorial too:
https://github.com/jjn1056/pagi/blob/main/lib/PAGI/Tutorial.pod
Beta Was this translation helpful? Give feedback.
All reactions