Skip to content

The donkey is an async donkey. #171

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

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,17 +499,17 @@ store = await storage("my-data-store", storage_class=MyStorage)

### `@pyscript/core/donkey`

Sometimes you need a Python worker ready and waiting to evaluate any code on
your behalf. This is the concept behind the JavaScript "donkey". We couldn't
think of a better way than "donkey" to describe something that is easy to
understand and shoulders the burden without complaint. This feature
Sometimes you need an asynchronous Python worker ready and waiting to evaluate
any code on your behalf. This is the concept behind the JavaScript "donkey". We
couldn't think of a better way than "donkey" to describe something that is easy
to understand and shoulders the burden without complaint. This feature
means you're able to use PyScript without resorting to specialised
`<script type="py">` style tags. It's just vanilla JavaScript.

Simply `import { donkey } from '@pyscript/core/dist/core.js'` and automatically
have both a *pyscript* module running on your page and a utility to bootstrap a
terminal based worker to evaluate any Python code as and when needed in the
future.
terminal based worker to asynchronously evaluate any Python code as and when
needed in the future.

```js title="A donkey worker"
import { donkey } from '@pyscript/core/dist/core.js';
Expand All @@ -521,7 +521,7 @@ const {
clear, // clear() the terminal
reset, // reset() the terminal (including colors)
kill, // kill() the worker forever
} = donkey({
} = await donkey({
type: 'py' || 'mpy', // the Python interpreter to run
persistent: false, // use `true` to track globals and locals
terminal: '', // optionally set a target terminal container
Expand Down