This would be handled by storing a Mojo::SQLite object instead of the dbh, or a DBIx::Connector object as you mentioned before.
On Thu, Jun 16, 2016 at 11:09 AM, Joel Berger <[email protected]> wrote: > Minion tasks are performed in forks to protect the integrity of the worker > process. Once the task is forked (or indeed after any fork) there must be a > new connection to the database, this is the only possible way to do > anything sane. > > > On Thursday, June 16, 2016 at 3:53:03 AM UTC-5, Yves wrote: >> >> I'm trying to implement a Minon worker that needs access to a database >> via DBI. >> >> Here is the code that I use : >> >> >> use Mojolicious::Lite; >> >> plugin Minion => { SQLite => 'sqlite:test.db' }; >> >> helper dbh => sub { >> my $dbh = DBI->connect("dbi:Oracle:somedb", 'someuser', >> 'somepasswd'); >> return $dbh; >> }; >> >> app->minion->add_task( mytask => \&mytask ); >> >> sub mytest { >> >> my ($job, $arg) = @_; >> >> my $dbh = $job->app->dbh; >> my ($time) = $dbh->selectrow_array('select sysdate from dual'); >> $job->finish('documentation generation done'); >> >> } >> app->start; >> >> >> The problem that I have, is that the connection to the database is >> closed/reopened on every task execution, which is very slow, and not the >> behavior that I expect. >> >> Using the same dbh helper on a Mojolicious app (not within minon task) >> works fine and opens one connection per worker. >> >> I've already tried various setups with DBI's InactiveDestroy parameter or >> using DBIx::Connector but no success so far. >> > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
