title: Can't get allowDiskUse:True to work with pymongo
body: <p>I'm running into the <code>aggregation result exceeds maximum document size (16MB)</code> error with mongodb aggregation using pymongo.</p>
  
  <p>I was able to overcome it at first using the <code>limit()</code> option. However, at some point I got the </p>
  
  <pre><code>Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in." error.
  </code></pre>
  
  <p>Ok, I'll use the <code>{'allowDiskUse':True}</code> option. This option works when I use it on the commandline, but when I tried to use in my python code</p>
  
  <pre><code>result = work1.aggregate(pipe, 'allowDiskUse:true')
  </code></pre>
  
  <p>I get <code>TypeError: aggregate() takes exactly 2 arguments (3 given)</code> error. (that's in spite of the definition given at <a href="http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.Collection.aggregate" rel="noreferrer">http://api.mongodb.org/python/current/api/pymongo/collection.html#pymongo.collection.Collection.aggregate</a>: aggregate(pipeline, **kwargs)).</p>
  
  <p>I tried to use runCommand, or rather it's pymongo equivalent:</p>
  
  <pre><code>db.command('aggregate','work1',pipe, {'allowDiskUse':True})
  </code></pre>
  
  <p>but now I'm back to the 'aggregation result exceeds maximum document size (16MB)' error</p>
  
  <p>In case you need to know</p>
  
  <pre><code>pipe = [{'$project': {'_id': 0, 'summary.trigrams': 1}}, {'$unwind': '$summary'}, {'$unwind': '$summary.trigrams'}, {'$group': {'count': {'$sum': 1}, '_id': '$summary.trigrams'}}, {'$sort': {'count': -1}}, {'$limit': 10000}]
  </code></pre>
  
  <p>Thank you</p>