-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: task.ensure_future or task.create_task #112
Comments
The new functions seem to work.
Assuming I haven't written the docs or added tests yet. |
Excellent! I should have a chance to test this later today. |
Limited testing shows this works perfectly. However, there isn't an easy way to add a done callback to a task. I was able to add this as a native python module to gain this functionality:
It's a slight departure from the real add_done_callback, as it allows arbitrary args and kwargs as long as the task is the first argument. But, I think this is an improvement. Used like this:
Perhaps we can add this as well? It'd be ideal if t10.add_done_callback() worked as is, but, it doesn't because it requires a sync method and all pyscript methods are async. I think syntax like this should be good enough:
|
Just saw this Exception:
It happened when I called pyscript.reload after running some test code using task.create() on methods that use task.unique() therefore resulting in cancelled tasks. I'm going to try to reproduce it now. |
I figured out where it's happening, I still don't know why.
I think. I was able to get this far by logging what is being cancelled (in function.py around line 97). However, it's always It's definitely the combination of my task_add_done_callback (above), task.unique(), and calling pyscript.reload() from in pyscript. Because if I take any one of those things out, the issue stops happening. |
This Exception was caused because I had a task running that was relying on I changed the way that operated (instead of I'm not sure if my code is bad, or if there's something pyscript should be cleaning up that it isn't. You can see the code here. Look for the word "Reaper" to see what I changed to make it work. https://gist.github.com/dlashua/f7d88f9a5afdcf7af17ce24266925a0b |
I've been able to reproduce this. But it has nothing to do with task.create. Opening a new issue and closing this one. |
I would like a way to say "run this other pyscript method without blocking execution of the current code path". Even better if this new method returns some kind of Future-like object that I can, later, get the result of, or cancel, or whatever. This method should take a pyscript method as an argument:
So I can, for instance do :
When running this, the log.info should only happen once and it should only sleep for 10-ish seconds.
Even better if I can pass arguments too:
task.create_task(report_a, param1, param2, other="thing")
The text was updated successfully, but these errors were encountered: