deckerego / ampule

A tiny HTTP server made for CircuitPython WiFi devices (like the ESP32)
MIT License
60 stars 10 forks source link

Added "poll" function/mode #25

Closed nightmechanic closed 1 year ago

nightmechanic commented 1 year ago

Thanks for this web server! I added a "poll" function to allow doing other stuff and while polling the socket once in a while, it is mostly adapted from the circuitpython webserver

deckerego commented 1 year ago

Thanks for the contribution @nightmechanic ! Can you add some corresponding tests & an example?

Interested in an example especially - I'm not 100% sure I understand the use case.

nightmechanic commented 1 year ago

@deckerego , No problem, will add a test and an example, (will take some time , a bit busy at work...) My purpose is to be able to do some "background" stuff while even when the remote client is idle and not sending any new connections/requests, which is a problem with the 'listen' method as it only returns when a connection is made. (for some reason I couldn't get the non-blocking feature of the socket to work, but this got me thinking again and wondering whether I tried it correctly....... ) If you are interested, in the mean time, you can take a look at my usage: https://github.com/nightmechanic/Autoflate_SW/blob/main/code.py , as can be seen it is still being developed and my coding skills could be better :) ( I am a HW guy most of the time)

deckerego commented 1 year ago

Merging into a feature branch & will add tests from there

deckerego commented 1 year ago

@nightmechanic - is this functionally the same as doing ampule.listen(socket, 0.0)?