2017-06-05 5 views
0

J'écris un écouteur de flux Twitter dans Python3 en utilisant Tweepy. Je reçois cette erreur après le streaming pendant un certain temps:Contourner l'exception IncompleteRead

urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) 

Comment puis-je contourner tout cela, reconnecter et continuer?

je l'ai fait:

from requests.packages.urllib3.exceptions import ReadTimeoutError, IncompleteRead 

Et:

while True: 
    try: 
     twitter_stream.filter(track=keywordlist, follow=userlist) 

    except IncompleteRead: 
     continue 

Mais encore obtenir l'erreur.

Répondre

3

L'exception que vous obtenez est une exception urllib3.exceptions.ProtocolError.

Essayez:

from urllib3.exceptions import ProtocolError 

while True: 
    try: 
     twitter_stream.filter(track=keywordlist, follow=userlist) 

    except ProtocolError: 
     continue 
+0

Bien sûr! Merci! J'ai remarqué juste en appuyant sur le bouton pour poster la question. – textnet