On 08/25/2014 06:24 PM, rasta wrote:
Hi,

I have two parallel XHR calls on my page, both arrives at Mango driver
(using morbo). The first one is non-blocking, the second blocking (but I
also tried non-blocking, no difference). The second would not work:

[Mon Aug 25 12:57:37 2014] [error] Non-blocking operations in progress at
/usr/local/share/perl/5.14.2/Mango/Cursor.pm line 206

The driver is initialized like this:

$self->helper(mango => sub { state $mango = Mango->new('mongodb://'.$config
->{mongodb}->{username}.':'.$config->{mongodb}->{password}.'@'.$config->{
mongodb}->{host}.'/'.$config->{mongodb}->{database}) });

Hey Rasta, you're better off doing this in your startup:

$self->attr(_mango => sub { return Mango->new(...) });
$self->helper(mango => return shift->app->_mango);

At least, that's how I generally do it.

And I'm using it (in both cases, just the first is a ->find() on another
collection) like:

$self->render_later;
$self->mango->db->collection('selections')->find_one({username => $username}
=> sub {
  my ($collection, $err, $doc) = @_;
  $self->render(json => { selection => $doc->{selection} }, status => 200);
});

I don't assume parallel requests could be an issue, I also don't see many
users having the same problem, what am I doing wrong?

The problem occurs when you are trying to execute a blocking operation when non-blocking operations are already in progress, the usual culprit for this are helpers. You'll have to find out what's causing a blocking operation to take place :)

--
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to