Open swelborn opened 3 months ago
Hi,
thanks you for the report, and very interesting use case, I like it! I would say this is appropriate use, the only think you shouldn't do is:
if debounce_update.pending:
debounce_update.cancel()
Sine that is implicitly done if you restart the task.
The printing of the exception is due to the automatic cancelling, and something not easily fixed.
The workaround for now is to use:
@task(prefer_threaded=False)
Let me know if that solves your problem.
Regards,
Maarten
That fixes it, and thanks for the info on implicit canceling on restart. Shall I close the issue or keep it open?
We can keep it open, since there is still an issue with the printing
Hello! Nice work on this. very cool.
I am using (potentially misusing) the task decorator functionality, and I am getting the errors below. Using bleeding edge version. You can see it takes a few times of sliding the slider until it errors. Maybe because Im creating so many tasks? Tried wrapping different parts of the code in try/excepts to no avail.
Details
pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending finished finished pending pending pending pending pending pending pending pending pending pending pending pending pending pending pending finished finished pending pending pending pending pending pending pending pending Future exception was never retrieved future:
Traceback (most recent call last):
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 235, in runs_in_thread
thread_event_loop.run_until_complete(current_task)
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 292, in _async_run
await runner()
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 266, in runner
self._last_value = value = await self.function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/swelborn/Documents/gits/tomopyui/sol.py", line 36, in debounce_update
await asyncio.sleep(1)
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/asyncio/tasks.py", line 649, in sleep
return await future
^^^^^^^^^^^^
asyncio.exceptions.CancelledError
Future exception was never retrieved
future:
Traceback (most recent call last):
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 235, in runs_in_thread
thread_event_loop.run_until_complete(current_task)
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 292, in _async_run
await runner()
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 266, in runner
self._last_value = value = await self.function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/swelborn/Documents/gits/tomopyui/sol.py", line 36, in debounce_update
await asyncio.sleep(1)
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/asyncio/tasks.py", line 649, in sleep
return await future
^^^^^^^^^^^^
asyncio.exceptions.CancelledError
Future exception was never retrieved
future:
Traceback (most recent call last):
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 235, in runs_in_thread
thread_event_loop.run_until_complete(current_task)
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 292, in _async_run
await runner()
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/site-packages/solara/tasks.py", line 266, in runner
self._last_value = value = await self.function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/swelborn/Documents/gits/tomopyui/sol.py", line 36, in debounce_update
await asyncio.sleep(1)
File "/Users/swelborn/miniconda3/envs/tomopyui-dev/lib/python3.11/asyncio/tasks.py", line 649, in sleep
return await future
^^^^^^^^^^^^
asyncio.exceptions.CancelledError
finished
finished