Skip to content

Poll class not working - urequest #298

@Marvell13

Description

@Marvell13

Urequest has no timeout parameter, I implemented the code below to use poll class

response = urequests.get(url=API_ENDPOINT,headers=headers)
  sock = response.raw
  sock.setblocking(True)
  poller = uselect.poll()
  poller.register(sock,uselect.POLLIN)
  events = poller.poll(1000)  # time in milliseconds
  print(events)
  if events:
     if uselect.POLLIN:
        text = sock.read()
        parsed = ujson.loads(text)
        print(parsed)
        response.close()
     else:
        print('POLLIN False'')
  else:            
     print('TIMEOUT  - events False')
          
 poller.unregister(sock)

after some execution time, the esp8266 hangs, not responding nor the terminal, stands at line 81 of lib urequest.py

l = s.readline()   ** freezes on this line
 #print(l)
 l = l.split(None, 2)
 status = int(l[1])
 reason = ""

I believe the end of the line has been lost. But the events = poller.poll(1000) # time in milliseconds should work, right ??

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy