Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

python - How to handle RemoteDisconnected when downloading data with zeep

I'm downloading some data from a wsdl api using zeep. When testing the code some errors occured so I'm trying to handle them with try except structures, but when the RemoteDisconnected error raises, I don't know exactly how to deal with it. My best attempt as far is the following:

def datos_factura(clave_acceso, wsdl_client):
try:    
    with wsdl_client.settings(raw_response=True):
        response = wsdl_client.service.autorizacionComprobante(clave_acceso)
        print(f'Comprobante no {clave_acceso}')
        print('Status: {}'.format(response.status_code))
except ConnectionError as connerror:
    print(connerror)
    check_later.append(clave_acceso)
    pass
except ConnectionAbortedError as connab:
    print(connab)
    check_later.append(clave_acceso)
    pass
except ConnectionRefusedError as connref:
    print(conneref)
    check_later.append(clave_acceso)
    pass
except ConnectionResetError as connreset:
    print(connereset)
    check_later.append(clave_acceso)
    pass
except http.client.RemoteDisconnected as rem:
    print(rem)
    check_later.append(clave_acceso)
finally:
    tree = et.fromstring(response.content.decode('utf-8'))

Please explain me the right way to catch that error

question from:https://stackoverflow.com/questions/65921205/how-to-handle-remotedisconnected-when-downloading-data-with-zeep

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...