I am running some map reduce jobs via the PHP client library as such:
$m = new Mongo(MY_CONN_STRING);
$db = $m->selectDB(MY_DB);
// run the map reduce function inside the DB
$db->command(array(
"mapreduce" => "CBD",
"map" => $map,
"reduce" => $reduce,
"query" => $filter,
"out" => $out));
I would like to return control to the thread straight away and let the map reduce command complete in the background, however at present MongoDB::command() is blocking.
Any ideas?
Not really. You could set a client-side timeout so that the command will immediately time out and then check the $out collection later, but you cannot ever retrieve the command result (or see if it succeeded).
Forcing an immediate timeout would look something like: