indigo-dc / flaat

FLAsk with Access Tokens - FLAAT
MIT License
11 stars 6 forks source link

make available the requests_cache backend configuration #12

Closed alexandru-u closed 4 years ago

alexandru-u commented 4 years ago

Hi,

Thank you for Flaat!

While using it with a Flask application on Azure AppService, we encountered an Azure bug: https://github.com/Azure/azure-sdk-for-python/issues/6503. This is because Flaat uses requests_cache with a default configuration using SQLite, which is the object of that bug. Can you provide a Flaat API to set/configure the backend for requests_cache? (I can confirm it works on Azure with memory configured as backend)

Cheers, Alexandru

PS I can do a Pull Request, if you don't have the time to add this functionality

marcvs commented 4 years ago

Thanks for this information.

PRs will be appreciated, as I can currently not promise to work on this timely. But I will try my best to improve flaat, because we use it internally, too.

marcvs commented 4 years ago

I've added some code (quick and not exactly clean). The caveat is that a default cache instance will be created, when you import flaat. You can later change that. If this works for you I'll merge that branch (make-cache-configurable) to master. Can you confirm, please.

alexandru-u commented 4 years ago

Marcvs, thank you for your quick response. I have tested your make-cache-configurable branch. For us not to encounter that Azure bug, we would need to have the backend initialized by 'memory' and not by 'sqlite' in issuertools.py->Cache_options()->init(self)->self.backend = 'sqlite'. If the backend is initialized by default to 'memory', no cache.sqlite file is created(thus no Azure bug triggered) and everything seems to be working fine.

marcvs commented 4 years ago

Ok, I've changed the default to memory. Does it work now?

alexandru-u commented 4 years ago

As I previously mentioned, it works (no Azure bug) with the backend default initialized to 'memory'. Thank you!

alexandru-u commented 4 years ago

Marcvs, do you know when this feature will be available via the flaat release via PyPI?

marcvs commented 4 years ago

I've just uploaded it.