google-research / planet

Learning Latent Dynamics for Planning from Pixels
https://danijar.com/planet
Apache License 2.0
1.18k stars 202 forks source link

AttrDict lock and unlock, what is it for? #8

Closed piojanu closed 5 years ago

piojanu commented 5 years ago

Hi!

I wonder what is the function of this locking mechanism in attr_dict.py:AttrDict. Is it supposed to make setting attributes thread safe? If yes then, shouldn't you use some kind of mutex? Those operations of setting and unsetting the '_unlocked' parameters are guaranteed to be atomic?

Thanks, Piotr

danijar commented 5 years ago

Thanks for the question. It has nothing to do with threading. It just prevents the user from accidentally change the contents of the dictionary, because the config dictionary should only be edited inside configs.py.