Dentosal / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
586 stars 182 forks source link

Fix property_cache_once_per_frame #240

Closed MythicManiac closed 5 years ago

MythicManiac commented 5 years ago

Current implementation of the "property_cache_once_per_frame" decorator doesn't work with multiple instances of the same class. This is due to the cache being stored to the function itself, rather than to the individual object it's being called on.

Address this issue by adding a parameter to the decorator, which can be used to define where the cache should be stored on the object, and store the cache there.

This allows multiple bots to co-exist in a single process without conflicting caches.

MythicManiac commented 5 years ago

Continuation of https://github.com/Dentosal/python-sc2/pull/210