Hi, thanks for your interest in the topic.
I made a clone and removed most of the unnecessary things from my application. Removing element by element, I discovered that the problem is somehow related to the image that I put in the place where a logo should be.
Link to clone: Anvil | Login
Please use the following details to log in:
Email: 123
Password: 123
After logging in, you need to click on the link that says “test1”. This is a view refreshed every second and the console should show RPC times around 1000ms - a lot but it works.
Now run Pico with the files below:
boot.py:
import network
from time import sleep
import ntptime
WIFI_SSID = "XXXXXXXXXXXX"
WIFI_PASSWORD = "YYYYYYYYYYYYY"
sleep(1)
wlan = None
while not wlan or wlan.status() != 3:
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(WIFI_SSID, WIFI_PASSWORD)
while True:
sleep(0.2)
if wlan.status() in [-1, -2, 3]:
break
ntptime.settime()
main.py
import anvil.pico
import uasyncio as a
from machine import Pin
import uasyncio
UPLINK_KEY = 'ZZZZZZZZZZZZZZZZZZZZZZZZ'
async def anvil_pico_call():
await anvil.pico.call('set_status', 'AvAwrNVJtG73lPTYLH1NjLXdJ2KZ77CG')
async def my_function():
while True:
print('my_function()')
uasyncio.create_task(anvil_pico_call())
uasyncio.create_task(anvil_pico_call())
# uasyncio.create_task(anvil_pico_call())
# uasyncio.create_task(anvil_pico_call())
# uasyncio.create_task(anvil_pico_call())
await uasyncio.sleep(1)
async def main():
uasyncio.create_task(anvil.pico.connect_async(UPLINK_KEY))
await uasyncio.create_task(my_function())
uasyncio.run(main())
Remember to set your WiFi details and your Server Uplink Key. After starting Pico, as above, i.e. with two calls, the RPC times immediately start to increase to a value of several seconds, after which the application stops working.
Now the best part. After deleting the image (Main form), the RPC time drops to 400-700 ms, which is better than before starting Pico. How is this possible? What’s the picture got to do with it? Considering the very small amount of data transferred, shouldn’t this time be less than 100 ms?
Finally, I did a test, no picture and ten calls per second. Pico stops working and displays the error over and over again:
Task exception wasn’t retrieved
future: coro= <generator object ‘anvil_pico_call’ at 20020960>
Traceback (most recent call last):
File “uasyncio/core.py”, line 1, in run_until_complete
File “main.py”, line 9, in anvil_pico_call
File “anvil/pico.py”, line 200, in call
MemoryError: memory allocation failed, allocating 3112 bytes
What would it look like if 10 devices made one call per second? Would the same problem exist?
The image I used:
Dimensions 1664x1664
Size 3.66 MB