jczic / MicroWebSrv2

The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
https://github.com/jczic/MicroWebSrv2
MIT License
662 stars 97 forks source link

pyboard 'socket' object has no attribute 'fileno' #30

Closed Meekdai closed 4 years ago

Meekdai commented 4 years ago

I found that socket has no attribute fileno when using MicroWebSrv2 on pyboard.

       ---------------------------
       - Python pkg MicroWebSrv2 -
       -      version 2.0.6      -
       -     by JC`zic & HC2     -
       ---------------------------

MWS2-INFO> Stops the managed pool.
Traceback (most recent call last):
  File "main.py", line 39, in <module>
  File "MicroWebSrv2/microWebSrv2.py", line 223, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 215, in StartManaged
  File "MicroWebSrv2/microWebSrv2.py", line 190, in StartInPool
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 381, in Create
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 392, in __init__
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 263, in __init__
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 151, in AddAsyncSocket
  File "MicroWebSrv2/libs/XAsyncSockets.py", line 56, in _addSocket
AttributeError: 'socket' object has no attribute 'fileno'
jczic commented 4 years ago

Hi @Meekdai and thank you for your feedback. It's right, fileno() function doesn't exists on some micropython versions. I've fixed this problem in XAsyncSockets lib by replacing socket.fileno() by id(socket). Could you update your MicroWebSrv2 repository and try it? Thank you again 👍

Meekdai commented 4 years ago

Thanks @jczic, now i can use MicroWebSrv2 on my pyboard.