Page 1 of 1

multitasking services

Posted: Fri Mar 17, 2017 8:57 am
by devnull
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 ?

Re: multitasking services

Posted: Fri Mar 17, 2017 10:48 am
by Roberthh
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

Posted: Sun Mar 19, 2017 11:46 pm
by fdushin
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

Re: multitasking services

Posted: Tue Apr 04, 2017 8:34 pm
by rosenrot
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
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.