Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tracking multiple tasks #148

Merged
merged 3 commits into from
Jul 17, 2024
Merged

Support tracking multiple tasks #148

merged 3 commits into from
Jul 17, 2024

Conversation

falkoschindler
Copy link
Contributor

Similar to NiceGUI's slot stacks, this PR implements separate @track stacks per task ID. Originally this was meant to solve issue #147, but it turned out that parallelized coroutines share the same task ID. Nevertheless, this PR should prevent the track stack from getting scrambled when calling tracked coroutines from different tasks, e.g. by clicking UI buttons.

@falkoschindler falkoschindler added the enhancement New feature or request label Jul 15, 2024
@rodja rodja added this to the 0.11.0 milestone Jul 15, 2024
@falkoschindler
Copy link
Contributor Author

I just merged this PR with the new implementation #150 and successfully tested with the following demo:

from nicegui import ui
import rosys

@rosys.analysis.track
async def short():
    await rosys.sleep(0.25)

@rosys.analysis.track
async def long():
    await rosys.sleep(0.75)

@rosys.analysis.track
async def run() -> None:
    await rosys.automation.parallelize(short(), long())

automator1 = rosys.automation.Automator(None, default_automation=run)
automator2 = rosys.automation.Automator(None, default_automation=run)

rosys.automation.automation_controls(automator1)
rosys.automation.automation_controls(automator2)
rosys.analysis.track.ui()

ui.run()

@falkoschindler falkoschindler marked this pull request as ready for review July 17, 2024 13:00
@falkoschindler falkoschindler merged commit 811fdf1 into main Jul 17, 2024
3 checks passed
@falkoschindler falkoschindler deleted the track-multi-task branch July 17, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants