diff --git a/docs/changelog.rst b/docs/changelog.rst index 2f2a496f..23489766 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -136,6 +136,9 @@ Core Library `closed` flag, preventing historical bugs where a double close could destroy descriptors belonging to unrelated streams. +* `#606 `_: fix example code on the + documentation front page. + * `a5536c35 `_: avoid quadratic buffer management when logging lines received from a child's redirected standard IO. @@ -150,11 +153,12 @@ bug reports, testing, features and fixes in this release contributed by `Anton Markelov `_, `Nigel Metheringham `_, `Orion Poplawski `_, +`Pieter Voet `_, +`Stefane Fermigier `_, `Szabó Dániel Ernő `_, `Ulrich Schreiner `_, `Yuki Nishida `_, -`@ghp-rr `_, -`Pieter Voet `_, and +`@ghp-rr `_, and `@rizzly `_. diff --git a/docs/index.rst b/docs/index.rst index 6b5deb71..c11a1d27 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -329,36 +329,7 @@ External contexts are configured such that any attempt to execute a function from the main Python script will correctly cause that script to be imported as usual into the slave process. -.. code-block:: python - - #!/usr/bin/env python - """ - Install our application on a remote machine. - - Usage: - install_app.py - - Where: - Hostname to install to. - """ - import os - import sys - - import mitogen - - - def install_app(): - os.system('tar zxvf my_app.tar.gz') - - - @mitogen.main() - def main(broker): - if len(sys.argv) != 2: - print(__doc__) - sys.exit(1) - - context = mitogen.ssh.connect(broker, sys.argv[1]) - context.call(install_app) +.. literalinclude:: ../examples/install_app.py Event-driven IO diff --git a/examples/install_app.py b/examples/install_app.py new file mode 100644 index 00000000..566353a8 --- /dev/null +++ b/examples/install_app.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +""" +Install our application on a remote machine. + +Usage: + install_app.py + +Where: + Hostname to install to. +""" +import os +import sys + +import mitogen + + +def install_app(): + os.system('tar zxvf my_app.tar.gz') + + +@mitogen.main() +def main(router): + if len(sys.argv) != 2: + print(__doc__) + sys.exit(1) + + context = router.ssh(hostname=sys.argv[1]) + context.call(install_app)