multitasking services

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

multitasking services

Post by devnull » Fri Mar 17, 2017 8:57 am

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 ?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: multitasking services

Post by Roberthh » Fri Mar 17, 2017 10:48 am

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.

User avatar
fdushin
Posts: 32
Joined: Thu Jul 21, 2016 5:38 pm

Re: multitasking services

Post by fdushin » Sun Mar 19, 2017 11:46 pm

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

rosenrot
Posts: 30
Joined: Mon Dec 12, 2016 9:39 pm

Re: multitasking services

Post by rosenrot » Tue Apr 04, 2017 8:34 pm

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.

Post Reply