There are some things that appear to be started as a service, for example webrepl and run in the background allowing for the main code to run independently.
So without threading, how is this achieved ?
multitasking services
Re: multitasking services
Webrepl uses a special non-standard mechanisms, which offers a callback mechsnism for sockets. That's all. The same mechanism can be used by python scripts, like by examples ot a ftp and telnet server, but this mechansism is not guaranteed to persist and is by no means a multitasking method. If a callback is triggered, it will interrupt the other code execution, how long that may take, until it returns.
Re: multitasking services
For a while I tried using some undocumented callbacks in the socket interface to allow server sockets to accept connections in the background [1]. This proved to be unworkable except in the most trivial cases, so I moved to using uasyncio, and the results are much better.
-Fred
[1] https://github.com/fadushin/esp8266/blo ... pd.py#L406
-Fred
[1] https://github.com/fadushin/esp8266/blo ... pd.py#L406
Re: multitasking services
I also tried [1] but it is just not useful for more advanced scenarios. Could you provide your uasync/socket code? Especially I'm interested in an onrecv and ondisconnect callback or something similar.fdushin wrote:For a while I tried using some undocumented callbacks in the socket interface to allow server sockets to accept connections in the background [1]. This proved to be unworkable except in the most trivial cases, so I moved to using uasyncio, and the results are much better.
-Fred
[1] https://github.com/fadushin/esp8266/blo ... pd.py#L406