Skip to content

Commit

Permalink
chore: Add deprecation warning. #1484
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Aug 10, 2023
1 parent b0530af commit 78d87a0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions py/h2o_wave/h2o_wave/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ async def run_on(q: Q) -> bool:
return False


_handle_on_deprecated_warning_printed = False


async def handle_on(q: Q) -> bool:
"""
Handle the query using a query handler (a function annotated with `@on()`).
Expand All @@ -189,6 +192,11 @@ async def handle_on(q: Q) -> bool:
Returns:
True if a matching query handler was found and invoked, else False.
"""
global _handle_on_deprecated_warning_printed
if not _handle_on_deprecated_warning_printed:
print('\033[93m' + 'Warning: handle_on() is deprecated, use run_on() instead.' + '\033[0m')
_handle_on_deprecated_warning_printed = True

event_sources = expando_to_dict(q.events)
for event_source in event_sources:
event = q.events[event_source]
Expand Down

0 comments on commit 78d87a0

Please sign in to comment.