-
Notifications
You must be signed in to change notification settings - Fork 47
Roadmap for Pyscript
Craig Barratt edited this page Aug 29, 2020
·
4 revisions
Here are some thoughts about features I plan to add. Please create an issue or edit this page if you have ideas or suggestions.
Currently there is only a short list of allowed imports, for two reasons:
- If people share pyscripts without inspecting them, they could include modules like
os
which could then be used to do bad things. Perhaps there could be a configuration setting that allows any imports, so you can set that if you want the current restriction removed. There could also be a configuration setting that allows additional modules you list, so you could allow specific additional imports without enabling everything. - Functions that can block (eg, doing I/O) should not be run in an async task, since they will block everything in that event loop until they complete. For example, the
json
module includesdump
andload
, which do I/O. A solution is to run just those functions in an executor job, which is a separate thread that allows the async task to resume once the function returns the result. There could be a new wrapper functiontask.executor_job(func)
that does this (which usesloop.run_in_executor
). It would be up to the user to recognize cases that need to be protected withtask.executor_job
. An alternative is to have this be done automatically, but I don't see a way to automatically determine which functions in a module need to be wrapped in this manner.
Add classes.
Add @unique_task
as a decorator with the same arguments and features as task.unique()
; see issue #1.
Currently @service
doesn't take any arguments, and the service name is pyscript.FUNC_NAME
, where FUNC_NAME
is the function name. An optional argument could be used to specify any service name.