Open AndyPermaRobotics opened 1 year ago
Thanks for reporting this @AndyPermaRobotics, but the example works fine here on MacOS. Are you testing this on Windows?
About the multiple evaluation of main you may want to have a look into the NiceGUI FAQ where I just added the infos from https://github.com/zauberzeug/nicegui/issues/794.
In RoSys we often use the last option with app.on_startup
in combination with a System class which manages the robot state. See our field friend code for example.
@rodja thanks for the link to the FAQ, my script works now.
It's interesting, that you could not reproduce the issue on MacOS. I let it run in a Docker Container.
Dockerfile:
FROM zauberzeug/rosys:latest
WORKDIR /usr/src/app
docker-compose.yml
version: "3.9"
services:
rosys_service:
build: .
tty: true
ports:
- "8080:8080"
volumes:
- ./:/app
hostname: docker
Ah very good @AndyPermaRobotics. With Docker the error comes up as described by you. Before I had just tested locally on mac.
@rodja Do you already have an idea what to do about it?
No, I have not looked into it.
I looked into this a little. I think the best way to solve this may be keeping Nicegui's behavior consistent in case there is no specific reason that it does not set the spawn method when reload=False
. However, I do not understand enough about Nicegui to fix this.
Another Option would be forcing the method to spawn instead of raising an exception in rosys.py on_startup
:
multiprocessing.set_start_method('spawn', force=True)
Hello everyone,
I have come across the following error message when I set the reload flag to False in the ui.run function:
To better localize the source of the error, I have created a minimal example where the error occurs. Just
import rosys
is enough.Example:
The error also occurs when I try to plan a path in my main program.
How did I come up with the idea of setting reload=False?
The reload flag causes my script to run twice. This results in two instances of each class being created. This has caused problems when I tried to subscribe to an MQTT topic, and my callback function was suddenly called twice for each message. The reload does not seem to be a complete restart where all resources from the previous run are cleaned up.