Skip to content

import rosys does not work with ui.run(reload=False) - RuntimeError: multiprocessing start method must be "spawn" #19

@AndyPermaRobotics

Description

@AndyPermaRobotics

Hello everyone,

I have come across the following error message when I set the reload flag to False in the ui.run function:

 Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/nicegui/background_tasks.py", line 55, in _handle_task_result
  task.result()
File "/usr/local/lib/python3.11/site-packages/nicegui/helpers.py", line 77, in result_with_client
  await result
File "/rosys/rosys/rosys.py", line 144, in startup
  raise RuntimeError(
RuntimeError: multiprocessing start method must be "spawn"; see https://pythonspeed.com/articles/python-multiprocessing/

To better localize the source of the error, I have created a minimal example where the error occurs. Just import rosys is enough.

Example:

from nicegui import ui

import rosys

ui.run(
    title='Test', 
    port=8080,
    reload=False
    )

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions