|
3 | 3 | import inspect
|
4 | 4 | import logging
|
5 | 5 |
|
| 6 | +import aiojobs |
| 7 | + |
6 | 8 | from aiocache.base import SENTINEL
|
7 | 9 | from aiocache.factory import Cache, caches
|
8 | 10 | from aiocache.lock import RedLock
|
9 | 11 |
|
10 | 12 |
|
11 | 13 | logger = logging.getLogger(__name__)
|
| 14 | +scheduler = asyncio.run(aiojobs.create_scheduler(pending_limit=0, limit=None)) |
12 | 15 |
|
13 | 16 |
|
14 | 17 | class cached:
|
@@ -112,9 +115,7 @@ async def decorator(
|
112 | 115 | if aiocache_wait_for_write:
|
113 | 116 | await self.set_in_cache(key, result)
|
114 | 117 | else:
|
115 |
| - # TODO: Use aiojobs to avoid warnings. |
116 |
| - asyncio.create_task(self.set_in_cache(key, result)) |
117 |
| - |
| 118 | + await scheduler.spawn(self.set_in_cache(key, result)) |
118 | 119 | return result
|
119 | 120 |
|
120 | 121 | def get_cache_key(self, f, args, kwargs):
|
@@ -336,8 +337,7 @@ async def decorator(
|
336 | 337 | if aiocache_wait_for_write:
|
337 | 338 | await self.set_in_cache(result, f, args, kwargs)
|
338 | 339 | else:
|
339 |
| - # TODO: Use aiojobs to avoid warnings. |
340 |
| - asyncio.create_task(self.set_in_cache(result, f, args, kwargs)) |
| 340 | + await scheduler.spawn(self.set_in_cache(result, f, args, kwargs)) |
341 | 341 |
|
342 | 342 | return result
|
343 | 343 |
|
|
0 commit comments