I see the problem now you have edited it to add the missing parts. It's the exception handler.
If you have an error after try
and before servers=[]
it will jump to the except clause, then see return servers
and fail.
You might want to use a list()
, instead of using a dict()
to emulate a list ...