use lock as context manager