Skip to content

[Bug] Odd behavior of ‘multitask’ at Spike Prime Hub #2468

@softyde

Description

@softyde

Description

When I use multitask on the Spike Prime Hub, it seems as if the race parameter is being ignored.
The function always works as if race=True was set, regardless of the value passed.
If the parameter is not passed (default =False), the function works as expected.

Tested with the current version at code.pybricks.com.

Reproduction

Program

from pybricks.tools import wait, multitask, run_task

async def main():
  pass
  print("main start")
  
  async def task_0():
    pass
    print("task_0 start")
    await wait(1000)
    print("task_0 done")
    
  
  async def task_1():
    pass
    print("task_1 start")    
    await wait(2000)
    print("task_1 done")    
  
  await multitask(task_0(), task_1(), race=False)
  
  print("main done")
  
run_task(main())

Output

main start
task_0 start
task_1 start
task_0 done
main done

Same behavior for race=True.

If you do not pass the parameter at all, both tasks finish as expected.

Program

from pybricks.tools import wait, multitask, run_task

async def main():
  pass
  print("main start")
  
  async def task_0():
    pass
    print("task_0 start")
    await wait(1000)
    print("task_0 done")
    
  
  async def task_1():
    pass
    print("task_1 start")    
    await wait(2000)
    print("task_1 done")    
  
  await multitask(task_0(), task_1())

  print("main done")
  
run_task(main())

Output

main start
task_0 start
task_1 start
task_0 done
task_1 done
main done

Screenshot

Image

Metadata

Metadata

Assignees

Labels

software: pybricks-micropythonIssues with Pybricks MicroPython firmware (or EV3 runtime)topic: multitaskingIssues releated to parallel threads, tasks, coroutines, etc.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions