posit-dev / posit-dev/py-shiny

Design pattern for global async reactive

Open
#698 1 comment 0 reactions 1 assignee View on GitHub

@jcheng5 is already working on this.

Since Aug 28, 2023.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

I'm looking for a design pattern that could be used to have a http request called every N seconds and use the response to set a global reactive.Value. It's a potentially expensive request/calculation, but the result is independent of the user requesting it. So i'd ideally like to perform the request once, (async to avoid blocking the reactivity) and then "distribute" the new value(s) to all users??

I've tried it with async keyword reactives as in this gist but the reactivity of inputs (not shown in the gist) and outputs e.g. the timer_out() output are "frozen" while waiting on the long-running api request.

I've had a look at multiprocessing to use the pattern described here, which i've used in shiny-R before, but that still seems to block from within the global async reactive.

I'm a bit rusty with python so I might well be missing something important.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.