Really what you should be doing is syncing changes back and forth
rather than pulling down the full list every time you want it. See
write-ups #3 and #4 here:
http://apidocs.mailchimp.com/api/how-to/
For an initial sync, use lists() to pull all of your lists like you
are now, then use the Export API's list() method to dump everything:
http://apidocs.mailchimp.com/export/1.0/list.func.php
That doesn't mean you won't run into an API error like a 502 at some
point, so your code should be able to recover from any errors.
jesse