3

I'm using Python 2.7 with SQLAlchemy. I'm trying to see if I can use Dogpile.Cache. I've installed dogpile cache using

pip install dogpile.cache

but when I try to run the example given by SQLAlchemy (helloworld.py) I keep getting ImportError: No module named fcntl. I thought the newest Dogpile.Cache resolved the windows issue...

Could someone please help? Thank you.

UPDATE

Ok, the example is creating the database and cache. But when it is trying to load data using FromCache it is giving me an error.

people = Session.query(Person).options(FromCache("default")).all()

Here is the Traceback

Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Users\JKIM\Downloads\DogpileCacheTest\examples\dogpile_caching\helloworld.py", line 13, in <module>
    people = Session.query(Person).options(FromCache("default")).all()
  File "build\bdist.win-amd64\egg\sqlalchemy\orm\query.py", line 2613, in all
  File "examples\caching_query.py", line 63, in __iter__
    return self.get_value(createfunc=lambda: list(Query.__iter__(self)))
  File "examples\caching_query.py", line 108, in get_value
    expiration_time=expiration_time
  File "C:\Python27\lib\site-packages\dogpile\cache\region.py", line 657, in get_or_create
    async_creator) as value:
  File "C:\Python27\lib\site-packages\dogpile\lock.py", line 154, in __enter__
    return self._enter()
  File "C:\Python27\lib\site-packages\dogpile\lock.py", line 87, in _enter
    value = value_fn()
  File "C:\Python27\lib\site-packages\dogpile\cache\region.py", line 610, in get_value
    value = self.backend.get(key)
  File "C:\Python27\lib\site-packages\dogpile\cache\backends\file.py", line 220, in get
    with self._dbm_file(False) as dbm:
  File "C:\Python27\lib\contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "C:\Python27\lib\site-packages\dogpile\cache\backends\file.py", line 212, in _dbm_file
    with self._use_rw_lock(write):
  File "C:\Python27\lib\contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "C:\Python27\lib\site-packages\dogpile\cache\backends\file.py", line 207, in _use_rw_lock
    with self._rw_lock.read():
  File "C:\Python27\lib\contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "C:\Python27\lib\site-packages\dogpile\cache\backends\file.py", line 327, in read
    self.acquire_read_lock(True)
  File "C:\Python27\lib\site-packages\dogpile\cache\backends\file.py", line 408, in acquire_read_lock
    return self._acquire(wait, os.O_RDONLY, self._module.LOCK_SH)
  File "C:\Python27\lib\site-packages\dogpile\util\langhelpers.py", line 63, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "C:\Python27\lib\site-packages\dogpile\cache\backends\file.py", line 400, in _module
    import fcntl
ImportError: No module named fcntl
monty_bean
  • 494
  • 5
  • 25
  • What OS are you using? – 7stud Jul 11 '16 at 19:52
  • I'm using Windows 7 – monty_bean Jul 11 '16 at 19:53
  • The python module `fcntl` is a Unix only module. You can't use software that employs python modules with Unix only features. – 7stud Jul 11 '16 at 19:55
  • Yes, I found this ticket in bitbucket (https://bitbucket.org/zzzeek/dogpile.cache/issues/44/cross-platform-file-caching) and was resolved. The newest version I installed was 0.6.1 and the issue was supposed to be resolved but seems like I cannot get it to work. – monty_bean Jul 11 '16 at 19:58
  • My reading of that issue is that a fix was NOT going to be added: *Windows just doesn't have a single, widely accepted approach for this kind of thing and I have no interest in endorsing one of them.* – 7stud Jul 11 '16 at 20:03
  • Oh, I see. Thank you. I guess I'll try Dutchreaper123's portalocker method. – monty_bean Jul 11 '16 at 20:06
  • Also, see here: http://stackoverflow.com/questions/1422368/fcntl-substitute-on-windows – 7stud Jul 11 '16 at 20:09
  • Ah, thank you. It's not just a simple issue... – monty_bean Jul 11 '16 at 20:52

0 Answers0