Skip to content

Roadmap for Pyscript

Craig Barratt edited this page Sep 1, 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.

Remove module import restriction

Currently there is only a short list of allowed imports, for two reasons:

  1. 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.
  2. 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 includes dump and load, 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 function task.executor_job(func) that does this (which uses loop.run_in_executor). It would be up to the user to recognize cases that need to be protected with task.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 more language features

Add classes, list/set/dict comprehensions. Try/except/raise were recently added, but need more testing.

Add @unique_task as decorator

Add @unique_task as a decorator with the same arguments and features as task.unique(); see issue #1.

Allow @service to include a service name argument

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.

Add "startup" as a @time_trigger specification

See issue #7.