Skip to content

Commit ab42bff

Browse files
committed
Add warning statements; Remove many print statements
1 parent 3319fb1 commit ab42bff

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

shiny/bookmark/_bookmark.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import warnings
34
from abc import ABC, abstractmethod
45
from pathlib import Path
56
from typing import TYPE_CHECKING, Awaitable, Callable, Literal, NoReturn
@@ -279,7 +280,6 @@ def _create_effects(self) -> None:
279280
if self.store == "disable":
280281
return
281282

282-
print("Creating effects")
283283
session = self._session_root
284284

285285
from .. import reactive
@@ -309,7 +309,6 @@ def init_error_message():
309309
# the server function has been executed.
310310
@reactive.effect(priority=1000000)
311311
async def invoke_on_restore_callbacks():
312-
print("Trying on restore")
313312
if self._on_restore_callbacks.count() == 0:
314313
return
315314

@@ -322,8 +321,10 @@ async def invoke_on_restore_callbacks():
322321
restore_state = self._restore_context.as_state()
323322
await self._on_restore_callbacks.invoke(restore_state)
324323
except Exception as e:
325-
raise e
326-
print(f"Error calling on_restore callback: {e}")
324+
warnings.warn(
325+
f"Error calling on_restore callback: {e}",
326+
stacklevel=2,
327+
)
327328
notification_show(
328329
f"Error calling on_restore callback: {e}",
329330
duration=None,
@@ -337,7 +338,6 @@ async def invoke_on_restore_callbacks():
337338
# until the next `on_flushed` invocation.
338339
@session.on_flush
339340
async def invoke_on_restored_callbacks():
340-
print("Trying on restored")
341341
if self._on_restored_callbacks.count() == 0:
342342
return
343343

@@ -348,7 +348,10 @@ async def invoke_on_restored_callbacks():
348348
restore_state = self._restore_context.as_state()
349349
await self._on_restored_callbacks.invoke(restore_state)
350350
except Exception as e:
351-
print(f"Error calling on_restored callback: {e}")
351+
warnings.warn(
352+
f"Error calling on_restored callback: {e}",
353+
stacklevel=2,
354+
)
352355
notification_show(
353356
f"Error calling on_restored callback: {e}",
354357
duration=None,

shiny/reactive/_core.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,15 @@ def on_flushed(
174174

175175
async def flush(self) -> None:
176176
"""Flush all pending operations"""
177-
print("--Reactive flush--")
178177
await self._flush_sequential()
179-
print("--Reactive flush callbacks--")
180178
await self._flushed_callbacks.invoke()
181-
print("--Reactive flush done--")
182179

183180
async def _flush_sequential(self) -> None:
184181
# Sequential flush: instead of storing the tasks in a list and calling gather()
185182
# on them later, just run each effect in sequence.
186-
print("--Sequential flush--")
187183
while not self._pending_flush_queue.empty():
188-
print("--item")
189184
ctx = self._pending_flush_queue.get()
190185
await ctx.execute_flush_callbacks()
191-
print("--Sequential flush done--")
192186

193187
def add_pending_flush(self, ctx: Context, priority: int) -> None:
194188
self._pending_flush_queue.put(priority, ctx)

shiny/session/_session.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,6 @@ def verify_state(expected_state: ConnectionState) -> None:
633633
return
634634

635635
async with lock():
636-
print("with lock")
637636
if message_obj["method"] == "init":
638637
verify_state(ConnectionState.Start)
639638

@@ -959,7 +958,6 @@ async def wrap_content_sync() -> AsyncIterable[bytes]:
959958
return HTMLResponse("<h1>Not Found</h1>", 404)
960959

961960
def send_input_message(self, id: str, message: dict[str, object]) -> None:
962-
print("Send input message", id, message)
963961
self._outbound_message_queues.add_input_message(id, message)
964962
self._request_flush()
965963

@@ -1039,9 +1037,7 @@ async def _flush(self) -> None:
10391037
with session_context(self):
10401038
# This is the only place in the session where the restoreContext is flushed.
10411039
if self.bookmark._restore_context:
1042-
print("Flushing restore context pending")
10431040
self.bookmark._restore_context.flush_pending()
1044-
print("Flushing restore context pending - done")
10451041
# Flush the callbacks
10461042
await self._flush_callbacks.invoke()
10471043

@@ -1055,13 +1051,11 @@ async def _flush(self) -> None:
10551051
}
10561052

10571053
try:
1058-
print("Sending message!", message)
10591054
await self._send_message(message)
10601055
finally:
10611056
self._outbound_message_queues.reset()
10621057
finally:
10631058
with session_context(self):
1064-
print("Invoking flushed callbacks")
10651059
await self._flushed_callbacks.invoke()
10661060

10671061
def _increment_busy_count(self) -> None:

0 commit comments

Comments
 (0)