Ok this makes it much clearer.

For this particular use, I have a lots of small tasks which require DB 
connection, but having a reconnection overhead for each task is just not 
acceptable.

If it's the only possible way maybe Minon is not the right tool. 

I'm a bit disapointed because except for this problem, it would be an 
excellent solution.

Thanks


On Thursday, 16 June 2016 17:09:12 UTC+2, Joel Berger 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.

Reply via email to