0

how do i use gridfs with libraries that dont accept non-blocking gridfs and only non-blocking other calls? i got error:

from mongotor.database import Database
import gridfs
db = Database.connect("localhost:27017", "mydb")
fs = gridfs.GridFS(db)

---------------------------------------------------------------------------
TypeError                                 
Traceback (most recent call last)
<ipython-input-4-e0f456d7d574> in <module>()
----> 1 fs = gridfs.GridFS(db)

C:\Python27\lib\site-packages\pymongo-2.3_-py2.7-win-amd64.egg\gridfs\__init__.pyc in     __init__(self, database, collection)
 49         """
 50         if not isinstance(database, Database):
---> 51             raise TypeError("database must be an instance of Database")
 52 
 53         self.__database = database

TypeError: database must be an instance of Database

Do i understand that gridfs MUST use only BLOCKING databases? (pymongo)

so then, do i use pymongo and mongotor, then i got:

from mongotor.database import Database
from pymongo import Connection
import gridfs
db = Database.connect("localhost:27017", "mydb")
dbb = Connection().mydb
fs = gridfs.GridFS(dbb)

So dbb will only be used when there is images to provide? it will block the db calls of course? so if someone is requesting picture then my non-blocking calls will block?

Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65

1 Answers1

2

The problem is that you are mixing pymongo and mongotor... the mongotor's database implementation is different from pymongo's database implementation, you can't use they together

MongoTor don't have, yet, support to gridfs, but you can use the gridfs provided by Motor, an asynchronous driver, like mongotor:

http://emptysquare.net/motor/pymongo/api/motor/examples/gridfs.html

nicolay
  • 36
  • 1