When emitting a state update, restore `_self_mutable` to the value it had
previously so that `yield` in the middle of `async with self` does not result
in an immutable StateProxy.
Fix#3869
* [REF-3184] Raise exception when encountering nested `async with self` blocks
Avoid deadlock when the background task already holds the mutation lock for a
given state.
* [REF-3339] get_state from background task links to StateProxy
When calling `get_state` from a background task, the resulting state instance
is wrapped in a StateProxy that is bound to the original StateProxy and shares
the same async context, lock, and mutability flag.
* If StateProxy has a _self_parent_state_proxy, retrieve the correct substate
* test_state fixup
* test_background_task: dispatch multiple async tasks
Use asyncio.gather to dispatch multiple tasks from a single background task
that all compete over the `async with self` lock. Even though the state itself
has a lock, each StateProxy instance should only allow a single `async with
self` context to run at a time.
* Protect StateProxy with an asyncio.Lock
Allow multiple tasks to reference the same StateProxy without stomping on each
other when entering an `async with self` context to acquire the state lock and
ultimately modify the state.
* test_client_storage: remove race conditions for cookie assignment
Poll for default timeout for cookies to appear in the controlled browser.
* Remove use of deprecated get_token and get_sid in core
Both reflex.app and reflex.state were still using deprecated methods, which
were throwing unsolvable warnings for end users.
* Remove deprecated router functions from integration tests
Mostly removing custom "token" var and replacing with
router.session.client_token.
Also replacing `get_query_params` and `get_current_page` usage as well.
* fix upload tests
Cannot pass substate as main app state, since it blocks us from accessing
"inherited vars"
* state: do NOT reset `router` to default
When calling `.reset` to reset state vars, do NOT reset the router data, as
that could mess up internal event processing.