Add basic doctest(ed) executor examples

Change-Id: I8940fe16299b02ec4d92479e06c884a72f401cec
This commit is contained in:
Joshua Harlow 2015-06-10 14:10:24 -07:00
parent cba2ef8169
commit 3d9ec12833
3 changed files with 107 additions and 1 deletions

View File

@ -22,7 +22,7 @@ sys.path.insert(0, os.path.abspath('../..'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
#'sphinx.ext.intersphinx',
'sphinx.ext.doctest',
'oslosphinx'
]

105
doc/source/examples.rst Normal file
View File

@ -0,0 +1,105 @@
========
Examples
========
-----------------------------------------
Creating and using a synchronous executor
-----------------------------------------
.. testcode::
import time
import futurist
def delayed_func():
time.sleep(0.1)
return "hello"
e = futurist.SynchronousExecutor()
fut = e.submit(delayed_func)
print(fut.result())
e.shutdown()
**Expected output:**
.. testoutput::
hello
------------------------------------------
Creating and using a thread-based executor
------------------------------------------
.. testcode::
import time
import futurist
def delayed_func():
time.sleep(0.1)
return "hello"
e = futurist.ThreadPoolExecutor()
fut = e.submit(delayed_func)
print(fut.result())
e.shutdown()
**Expected output:**
.. testoutput::
hello
------------------------------------------------
Creating and using a green thread-based executor
------------------------------------------------
.. testcode::
import time
import futurist
def delayed_func():
time.sleep(0.1)
return "hello"
e = futurist.GreenThreadPoolExecutor()
fut = e.submit(delayed_func)
print(fut.result())
e.shutdown()
**Expected output:**
.. testoutput::
hello
-------------------------------------------
Creating and using a process-based executor
-------------------------------------------
.. testcode::
import time
import futurist
def delayed_func():
time.sleep(0.1)
return "hello"
e = futurist.ProcessPoolExecutor()
fut = e.submit(delayed_func)
print(fut.result())
e.shutdown()
**Expected output:**
.. testoutput::
hello

View File

@ -9,6 +9,7 @@ Code from the future, delivered to you in the **now**.
features
api
installation
examples
contributing
Indices and tables