Merge "Modification of the example code"

This commit is contained in:
Jenkins 2016-01-15 13:14:19 +00:00 committed by Gerrit Code Review
commit a57e1c8dba
1 changed files with 48 additions and 31 deletions

View File

@ -8,24 +8,67 @@ Creating and using a synchronous executor
.. testcode::
import time
# NOTE: enable printing timestamp for additional data
import sys
import futurist
import eventlet
def delayed_func():
time.sleep(0.1)
return "hello"
print("started")
eventlet.sleep(3)
print("done")
#print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
e = futurist.SynchronousExecutor()
fut = e.submit(delayed_func)
print(fut.result())
eventlet.sleep(1)
print("Hello")
eventlet.sleep(1)
e.shutdown()
#print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
**Expected output:**
.. testoutput::
hello
started
done
Hello
------------------------------------------------
Creating and using a green thread-based executor
------------------------------------------------
.. testcode::
# NOTE: enable printing timestamp for additional data
import sys
import futurist
import eventlet
def delayed_func():
print("started")
eventlet.sleep(3)
print("done")
#print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
e = futurist.GreenThreadPoolExecutor()
fut = e.submit(delayed_func)
eventlet.sleep(1)
print("Hello")
eventlet.sleep(1)
e.shutdown()
#print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
**Expected output:**
.. testoutput::
started
Hello
done
------------------------------------------
@ -53,32 +96,6 @@ Creating and using a thread-based executor
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
-------------------------------------------