Discussion:
[Python-checkins] cpython (merge 3.4 -> default): merge 3.4
benjamin.peterson
2014-10-13 19:51:39 UTC
Permalink
https://hg.python.org/cpython/rev/390ede7de560
changeset: 93037:390ede7de560
parent: 93036:6015b23bf918
parent: 93035:f4e291263a6d
user: Benjamin Peterson <benjamin at python.org>
date: Mon Oct 13 15:51:21 2014 -0400
summary:
merge 3.4

files:
--
Repository URL: https://hg.python.org/cpython
benjamin.peterson
2014-10-13 19:51:39 UTC
Permalink
https://hg.python.org/cpython/rev/2b5707b6caf9
changeset: 93034:2b5707b6caf9
parent: 93023:c0224ff67cdd
parent: 93033:64684ebadec0
user: Benjamin Peterson <benjamin at python.org>
date: Mon Oct 13 11:55:11 2014 -0400
summary:
merge 3.4

files:
Doc/library/xmlrpc.client.rst | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)


diff --git a/Doc/library/xmlrpc.client.rst b/Doc/library/xmlrpc.client.rst
--- a/Doc/library/xmlrpc.client.rst
+++ b/Doc/library/xmlrpc.client.rst
@@ -27,6 +27,11 @@
constructed data. If you need to parse untrusted or unauthenticated data see
:ref:`xml-vulnerabilities`.

+.. warning::
+
+ In the case of https URIS, :mod:`xmlrpc.client` does not do any verification
+ of the server's certificate.
+

.. class:: ServerProxy(uri, transport=None, encoding=None, verbose=False, \
allow_none=False, use_datetime=False, \
--
Repository URL: https://hg.python.org/cpython
benjamin.peterson
2014-10-13 20:34:11 UTC
Permalink
https://hg.python.org/cpython/rev/18be8ceaa20f
changeset: 93043:18be8ceaa20f
parent: 93040:77321a189ecb
parent: 93042:49b3829e59a3
user: Benjamin Peterson <benjamin at python.org>
date: Mon Oct 13 16:34:06 2014 -0400
summary:
merge 3.4

files:
--
Repository URL: https://hg.python.org/cpython
benjamin.peterson
2014-10-15 17:48:26 UTC
Permalink
https://hg.python.org/cpython/rev/72cfca354c92
changeset: 93083:72cfca354c92
parent: 93081:ffabb674140c
parent: 93082:5fd481150b35
user: Benjamin Peterson <benjamin at python.org>
date: Wed Oct 15 13:40:46 2014 -0400
summary:
merge 3.4

files:
Doc/library/asyncio-eventloop.rst | 61 +++++++++++++++---
Doc/library/asyncio-task.rst | 58 +++++++++++++----
2 files changed, 94 insertions(+), 25 deletions(-)


diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -649,24 +649,27 @@

.. _asyncio-hello-world-callback:

-Hello World with a callback
----------------------------
+Hello World with call_soon()
+----------------------------

-Print ``"Hello World"`` every two seconds using a callback scheduled by the
-:meth:`BaseEventLoop.call_soon` method::
+Example using the :meth:`BaseEventLoop.call_soon` method to schedule a
+callback. The callback displays ``"Hello World"`` and then stops the event
+loop::

import asyncio

- def print_and_repeat(loop):
+ def hello_world(loop):
print('Hello World')
- loop.call_later(2, print_and_repeat, loop)
+ loop.stop()

loop = asyncio.get_event_loop()
- loop.call_soon(print_and_repeat, loop)
- try:
- loop.run_forever()
- finally:
- loop.close()
+
+ # Schedule a call to hello_world()
+ loop.call_soon(hello_world, loop)
+
+ # Blocking call interrupted by loop.stop()
+ loop.run_forever()
+ loop.close()

.. seealso::

@@ -674,6 +677,42 @@
uses a :ref:`coroutine <coroutine>`.


+.. _asyncio-date-callback:
+
+Display the current date with call_later()
+------------------------------------------
+
+Example of callback displaying the current date every second. The callback uses
+the :meth:`BaseEventLoop.call_later` method to reschedule itself during 5
+seconds, and then stops the event loop::
+
+ import asyncio
+ import datetime
+
+ def display_date(end_time, loop):
+ print(datetime.datetime.now())
+ if (loop.time() + 1.0) < end_time:
+ loop.call_later(1, display_date, end_time, loop)
+ else:
+ loop.stop()
+
+ loop = asyncio.get_event_loop()
+
+ # Schedule the first call to display_date()
+ end_time = loop.time() + 5.0
+ loop.call_soon(display_date, end_time, loop)
+
+ # Blocking call interrupted by loop.stop()
+ loop.run_forever()
+ loop.close()
+
+.. seealso::
+
+ The :ref:`coroutine displaying the current date
+ <asyncio-date-coroutine>` example uses a :ref:`coroutine
+ <coroutine>`.
+
+
.. _asyncio-watch-read-event:

Watch a file descriptor for read events
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst
--- a/Doc/library/asyncio-task.rst
+++ b/Doc/library/asyncio-task.rst
@@ -77,30 +77,60 @@

.. _asyncio-hello-world-coroutine:

-Example: "Hello World" coroutine
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Example: Hello World coroutine
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-Print ``"Hello World"`` every two seconds using a coroutine::
+Example of coroutine displaying ``"Hello World"``::

import asyncio

@asyncio.coroutine
- def greet_every_two_seconds():
- while True:
- print('Hello World')
- yield from asyncio.sleep(2)
+ def hello_world():
+ print("Hello World!")

loop = asyncio.get_event_loop()
- try:
- loop.run_until_complete(greet_every_two_seconds())
- finally:
- loop.close()
+ # Blocking call which returns when the hello_world() coroutine is done
+ loop.run_until_complete(hello_world())
+ loop.close()

.. seealso::

- The :ref:`Hello World with a callback <asyncio-hello-world-callback>`
- example uses a callback scheduled by the :meth:`BaseEventLoop.call_soon`
- method.
+ The :ref:`Hello World with call_soon() <asyncio-hello-world-callback>`
+ example uses the :meth:`BaseEventLoop.call_soon` method to schedule a
+ callback.
+
+
+.. _asyncio-date-coroutine:
+
+Example: Coroutine displaying the current date
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Example of coroutine displaying the current date every second during 5 seconds
+using the :meth:`sleep` function::
+
+ import asyncio
+ import datetime
+
+ @asyncio.coroutine
+ def display_date(loop):
+ end_time = loop.time() + 5.0
+ while True:
+ print(datetime.datetime.now())
+ if (loop.time() + 1.0) >= end_time:
+ break
+ yield from asyncio.sleep(1)
+
+ loop = asyncio.get_event_loop()
+ # Blocking call which returns when the display_date() coroutine is done
+ loop.run_until_complete(display_date(loop))
+ loop.close()
+
+.. seealso::
+
+ The :ref:`display the current date with call_later()
+ <asyncio-date-callback>` example uses a callback with the
+ :meth:`BaseEventLoop.call_later` method.
+

Example: Chain coroutines
^^^^^^^^^^^^^^^^^^^^^^^^^
--
Repository URL: https://hg.python.org/cpython
benjamin.peterson
2014-10-16 04:03:40 UTC
Permalink
https://hg.python.org/cpython/rev/0ab23958c2a7
changeset: 93093:0ab23958c2a7
parent: 93090:14e62e632fbe
parent: 93092:2f90ea9e60ef
user: Benjamin Peterson <benjamin at python.org>
date: Wed Oct 15 23:58:37 2014 -0400
summary:
merge 3.4

files:
--
Repository URL: https://hg.python.org/cpython
Loading...