Asynchronously set cache using run_in_executor to avoid blocking the event loop. Compatible with Python 3.8+.
(self, key, value, **kwargs)
| 100 | print_verbose(f"S3 Caching: set_cache() - Got exception from S3: {e}") |
| 101 | |
| 102 | async def async_set_cache(self, key, value, **kwargs): |
| 103 | """ |
| 104 | Asynchronously set cache using run_in_executor to avoid blocking the event loop. |
| 105 | Compatible with Python 3.8+. |
| 106 | """ |
| 107 | try: |
| 108 | verbose_logger.debug("Set ASYNC S3 Cache: Key=%s. Value=%s", key, value) |
| 109 | loop: Final = asyncio.get_event_loop() |
| 110 | func: Final = partial(self.set_cache, key, value, **kwargs) |
| 111 | await loop.run_in_executor(None, func) |
| 112 | except Exception as e: |
| 113 | verbose_logger.error("S3 Caching: async_set_cache() - Got exception from S3: %s", e) |
| 114 | |
| 115 | def get_cache(self, key, **kwargs): |
| 116 | import botocore |