momosecurity / aswan

陌陌风控系统静态规则引擎,零基础简易便捷的配置多种复杂规则,实时高效管控用户异常行为。
GNU Lesser General Public License v2.1
2.99k stars 828 forks source link

bug: delete OrderedDict during iteration #9

Closed islishude closed 5 years ago

islishude commented 5 years ago
Traceback (most recent call last):
  File "/Users/islishude/Library/Python/3.7/lib/python/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/islishude/Library/Python/3.7/lib/python/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
    response = middleware_method(request)
  File "/Users/islishude/project/aswan/www/permissions/middleware.py", line 45, in process_request
    if not cls.has_perm(user.email, path):
  File "/Users/islishude/project/aswan/www/permissions/middleware.py", line 51, in has_perm
    return CACHE_HAS_PERMS[(pk, path)]
  File "/Users/islishude/project/aswan/www/core/lru.py", line 39, in withlock
    return func(self, *args, **kwargs)
  File "/Users/islishude/project/aswan/www/core/lru.py", line 172, in __getitem__
    self.cleanup()
  File "/Users/islishude/project/aswan/www/core/lru.py", line 39, in withlock
    return func(self, *args, **kwargs)
  File "/Users/islishude/project/aswan/www/core/lru.py", line 189, in cleanup
    for k in self.__expire_times:
RuntimeError: OrderedDict mutated during iteration

I will make a PR to fix it.

leohowell commented 5 years ago

Well done!