From 728348e1c2f19c68206181002734675b8af9fef3 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 5 Sep 2024 11:16:44 -0400 Subject: [PATCH 1/2] white space formatting for return value --- shiny/reactive/_poll.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/shiny/reactive/_poll.py b/shiny/reactive/_poll.py index 81d673834..bcfe7807c 100644 --- a/shiny/reactive/_poll.py +++ b/shiny/reactive/_poll.py @@ -87,10 +87,10 @@ def poll( ------- : A decorator that should be applied to a no-argument function that (expensively) - reads whatever data is desired. (This function may be a regular function or a - co-routine function.) The result of the decorator is a reactive - :func:`~shiny.reactive.calc` that always returns up-to-date data, and invalidates - callers when changes are detected via polling. + reads whatever data is desired. (This function may be a regular function or a + co-routine function.) The result of the decorator is a reactive + :func:`~shiny.reactive.calc` that always returns up-to-date data, and + invalidates callers when changes are detected via polling. See Also -------- @@ -103,6 +103,7 @@ def poll( @reactive.effect(priority=priority, session=session) async def _(): + print("\ncheck") try: if _utils.is_async_callable(poll_func): new = await poll_func() @@ -114,6 +115,7 @@ async def _(): try: is_equal = equals(old, new) + print("equals", old, new, is_equal) except Exception as e: # For example, pandas DataFrame throws if you try to compare it to a # non-comparable object @@ -144,11 +146,16 @@ async def _(): # cleared, but don't unnecessarily call last_error.set(); at the time of # this writing, we haven't made a final decision on whether reactive.Value # will ignore sets if the new value is identical to the existing one. + print("successful comparison") with reactive.isolate(): + print("last_error.get()", last_error.get()) if last_error.get() is not None: + print("Setting last_error to `None`") last_error.set(None) + print("is_equal", is_equal) if not is_equal: + print("Setting last_value to `new`", new) last_value.set(new) except Exception as e: # Either the polling function threw an error, or we failed to compare its @@ -184,9 +191,13 @@ async def result_async() -> T: else: + print("sync fn!!") + print("Session", session) + @reactive.calc(session=session) @functools.wraps(fn) def result_sync() -> T: + print("result_sync") # If an error occurred, raise it err = last_error.get() if err is not None: From 4da8a88c698c04d56f26f2bfe04538e8e7733bda Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Thu, 5 Sep 2024 11:18:51 -0400 Subject: [PATCH 2/2] Update _poll.py --- shiny/reactive/_poll.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/shiny/reactive/_poll.py b/shiny/reactive/_poll.py index bcfe7807c..24004eaf8 100644 --- a/shiny/reactive/_poll.py +++ b/shiny/reactive/_poll.py @@ -103,7 +103,6 @@ def poll( @reactive.effect(priority=priority, session=session) async def _(): - print("\ncheck") try: if _utils.is_async_callable(poll_func): new = await poll_func() @@ -115,7 +114,6 @@ async def _(): try: is_equal = equals(old, new) - print("equals", old, new, is_equal) except Exception as e: # For example, pandas DataFrame throws if you try to compare it to a # non-comparable object @@ -146,16 +144,11 @@ async def _(): # cleared, but don't unnecessarily call last_error.set(); at the time of # this writing, we haven't made a final decision on whether reactive.Value # will ignore sets if the new value is identical to the existing one. - print("successful comparison") with reactive.isolate(): - print("last_error.get()", last_error.get()) if last_error.get() is not None: - print("Setting last_error to `None`") last_error.set(None) - print("is_equal", is_equal) if not is_equal: - print("Setting last_value to `new`", new) last_value.set(new) except Exception as e: # Either the polling function threw an error, or we failed to compare its @@ -191,13 +184,9 @@ async def result_async() -> T: else: - print("sync fn!!") - print("Session", session) - @reactive.calc(session=session) @functools.wraps(fn) def result_sync() -> T: - print("result_sync") # If an error occurred, raise it err = last_error.get() if err is not None: