Twython Incomplete Read HTTP ChunkEncodingError Python 3












0















I wrote a script using Twython that uses the Streamer calls. It works fine running under an Anaconda window on my Windows 10 PC. I tested it for 3 days and nights continuously and it never quit.



I just transferred it to a Raspberry Pi 3 where I ran update and upgrade, then copied over my script using Putty to connect to SSH. Raspian OS. When I run the script under Python3, I get the following run time error when the streamer crashes. Note the streamer has a on_error method that should trap the error, but it is completely bypassed and the script terminates. The Pi has a direct Ethernet connection to the router.



Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in
read data = self._fp.read(amt)
File "/usr/lib/python3.4/http/client.py", line 500, in read
return super(HTTPResponse, self).read(amt)
File "/usr/lib/python3.4/http/client.py", line 529, in readinto
return self._readinto_chunked(b)
File "/usr/lib/python3.4/http/client.py", line 621, in _readinto_chunked
n = self._safe_readinto(mvb)
File "/usr/lib/python3.4/http/client.py", line 680, in _safe_readinto
raise IncompleteRead(bytes(mvb[0:total_bytes]), len(b))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)


This does not have anything to do with my actual code, I'm not clear on how to troubleshoot.



UPDATE: after 3 days running on the PC I just got a similar error. So I put the streamer in a Try Except with continue loop and I will see what happens. Apparently this problem has been around with Twython for a long time. I will update again if I learn anything.



UPDATE: I modified the code based on another post, to trap errors missed by the Streamer on_error event, to look like this:



## try to ignore http errors crashing the system
while True:
try:
stream.statuses.filter(follow=users, language = 'en')

except:
e = sys.exc_info()[0]
print('ERROR:',e )
continue


This ran error free overnight on the PC. Not a single error occurred. I moved the code over to the Raspberry Pi, which is headless and which i run with Putty from the PC, and it runs fine now - EXCEPT, I get an error a few times per hour. The stream restarts and seems to run fine otherwise. Not sure why. The screen looks like this:



Testing 1 2 3 4 5
file updated

Testing again 1 2 3 4
file updated
ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
ERROR: <class 'requests.exceptions.ChunkedEncodingError'>


The HTTP Requests documentation says this about the error:



class ChunkedEncodingError(RequestException):
"""The server declared chunked encoding but sent an invalid chunk."""


So I have to assume there is some internal problem with Twython? Or ?










share|improve this question





























    0















    I wrote a script using Twython that uses the Streamer calls. It works fine running under an Anaconda window on my Windows 10 PC. I tested it for 3 days and nights continuously and it never quit.



    I just transferred it to a Raspberry Pi 3 where I ran update and upgrade, then copied over my script using Putty to connect to SSH. Raspian OS. When I run the script under Python3, I get the following run time error when the streamer crashes. Note the streamer has a on_error method that should trap the error, but it is completely bypassed and the script terminates. The Pi has a direct Ethernet connection to the router.



    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in
    read data = self._fp.read(amt)
    File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
    File "/usr/lib/python3.4/http/client.py", line 529, in readinto
    return self._readinto_chunked(b)
    File "/usr/lib/python3.4/http/client.py", line 621, in _readinto_chunked
    n = self._safe_readinto(mvb)
    File "/usr/lib/python3.4/http/client.py", line 680, in _safe_readinto
    raise IncompleteRead(bytes(mvb[0:total_bytes]), len(b))
    http.client.IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)


    This does not have anything to do with my actual code, I'm not clear on how to troubleshoot.



    UPDATE: after 3 days running on the PC I just got a similar error. So I put the streamer in a Try Except with continue loop and I will see what happens. Apparently this problem has been around with Twython for a long time. I will update again if I learn anything.



    UPDATE: I modified the code based on another post, to trap errors missed by the Streamer on_error event, to look like this:



    ## try to ignore http errors crashing the system
    while True:
    try:
    stream.statuses.filter(follow=users, language = 'en')

    except:
    e = sys.exc_info()[0]
    print('ERROR:',e )
    continue


    This ran error free overnight on the PC. Not a single error occurred. I moved the code over to the Raspberry Pi, which is headless and which i run with Putty from the PC, and it runs fine now - EXCEPT, I get an error a few times per hour. The stream restarts and seems to run fine otherwise. Not sure why. The screen looks like this:



    Testing 1 2 3 4 5
    file updated

    Testing again 1 2 3 4
    file updated
    ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
    ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
    ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
    ERROR: <class 'requests.exceptions.ChunkedEncodingError'>


    The HTTP Requests documentation says this about the error:



    class ChunkedEncodingError(RequestException):
    """The server declared chunked encoding but sent an invalid chunk."""


    So I have to assume there is some internal problem with Twython? Or ?










    share|improve this question



























      0












      0








      0








      I wrote a script using Twython that uses the Streamer calls. It works fine running under an Anaconda window on my Windows 10 PC. I tested it for 3 days and nights continuously and it never quit.



      I just transferred it to a Raspberry Pi 3 where I ran update and upgrade, then copied over my script using Putty to connect to SSH. Raspian OS. When I run the script under Python3, I get the following run time error when the streamer crashes. Note the streamer has a on_error method that should trap the error, but it is completely bypassed and the script terminates. The Pi has a direct Ethernet connection to the router.



      Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in
      read data = self._fp.read(amt)
      File "/usr/lib/python3.4/http/client.py", line 500, in read
      return super(HTTPResponse, self).read(amt)
      File "/usr/lib/python3.4/http/client.py", line 529, in readinto
      return self._readinto_chunked(b)
      File "/usr/lib/python3.4/http/client.py", line 621, in _readinto_chunked
      n = self._safe_readinto(mvb)
      File "/usr/lib/python3.4/http/client.py", line 680, in _safe_readinto
      raise IncompleteRead(bytes(mvb[0:total_bytes]), len(b))
      http.client.IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)


      This does not have anything to do with my actual code, I'm not clear on how to troubleshoot.



      UPDATE: after 3 days running on the PC I just got a similar error. So I put the streamer in a Try Except with continue loop and I will see what happens. Apparently this problem has been around with Twython for a long time. I will update again if I learn anything.



      UPDATE: I modified the code based on another post, to trap errors missed by the Streamer on_error event, to look like this:



      ## try to ignore http errors crashing the system
      while True:
      try:
      stream.statuses.filter(follow=users, language = 'en')

      except:
      e = sys.exc_info()[0]
      print('ERROR:',e )
      continue


      This ran error free overnight on the PC. Not a single error occurred. I moved the code over to the Raspberry Pi, which is headless and which i run with Putty from the PC, and it runs fine now - EXCEPT, I get an error a few times per hour. The stream restarts and seems to run fine otherwise. Not sure why. The screen looks like this:



      Testing 1 2 3 4 5
      file updated

      Testing again 1 2 3 4
      file updated
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>


      The HTTP Requests documentation says this about the error:



      class ChunkedEncodingError(RequestException):
      """The server declared chunked encoding but sent an invalid chunk."""


      So I have to assume there is some internal problem with Twython? Or ?










      share|improve this question
















      I wrote a script using Twython that uses the Streamer calls. It works fine running under an Anaconda window on my Windows 10 PC. I tested it for 3 days and nights continuously and it never quit.



      I just transferred it to a Raspberry Pi 3 where I ran update and upgrade, then copied over my script using Putty to connect to SSH. Raspian OS. When I run the script under Python3, I get the following run time error when the streamer crashes. Note the streamer has a on_error method that should trap the error, but it is completely bypassed and the script terminates. The Pi has a direct Ethernet connection to the router.



      Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/urllib3/response.py", line 186, in
      read data = self._fp.read(amt)
      File "/usr/lib/python3.4/http/client.py", line 500, in read
      return super(HTTPResponse, self).read(amt)
      File "/usr/lib/python3.4/http/client.py", line 529, in readinto
      return self._readinto_chunked(b)
      File "/usr/lib/python3.4/http/client.py", line 621, in _readinto_chunked
      n = self._safe_readinto(mvb)
      File "/usr/lib/python3.4/http/client.py", line 680, in _safe_readinto
      raise IncompleteRead(bytes(mvb[0:total_bytes]), len(b))
      http.client.IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)


      This does not have anything to do with my actual code, I'm not clear on how to troubleshoot.



      UPDATE: after 3 days running on the PC I just got a similar error. So I put the streamer in a Try Except with continue loop and I will see what happens. Apparently this problem has been around with Twython for a long time. I will update again if I learn anything.



      UPDATE: I modified the code based on another post, to trap errors missed by the Streamer on_error event, to look like this:



      ## try to ignore http errors crashing the system
      while True:
      try:
      stream.statuses.filter(follow=users, language = 'en')

      except:
      e = sys.exc_info()[0]
      print('ERROR:',e )
      continue


      This ran error free overnight on the PC. Not a single error occurred. I moved the code over to the Raspberry Pi, which is headless and which i run with Putty from the PC, and it runs fine now - EXCEPT, I get an error a few times per hour. The stream restarts and seems to run fine otherwise. Not sure why. The screen looks like this:



      Testing 1 2 3 4 5
      file updated

      Testing again 1 2 3 4
      file updated
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>
      ERROR: <class 'requests.exceptions.ChunkedEncodingError'>


      The HTTP Requests documentation says this about the error:



      class ChunkedEncodingError(RequestException):
      """The server declared chunked encoding but sent an invalid chunk."""


      So I have to assume there is some internal problem with Twython? Or ?







      python http raspberry-pi3 twython






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 15:44







      Glenn

















      asked Nov 15 '18 at 19:49









      GlennGlenn

      83111




      83111
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326937%2ftwython-incomplete-read-http-chunkencodingerror-python-3%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326937%2ftwython-incomplete-read-http-chunkencodingerror-python-3%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues