PROTON-2405: Change python examples to be python3 only
diff --git a/python/examples/README.txt b/python/examples/README.txt
index 41a6bbd..512ca4c 100644
--- a/python/examples/README.txt
+++ b/python/examples/README.txt
@@ -2,8 +2,22 @@
 similar intermediary that supports the AMQP 1.0 protocol, allows
 anonymous connections and accepts links to and from a node named
 'examples'. A very simple broker emulating script - broker.py - is
-provided against which the examples can also be run (transactions are
-not yet supported in this script).
+provided against which some of the examples can also be run.
+
+Transactions and selectors are not yet supported in this script, so the
+examples that require these features (tx_recy.py, tx_send.py,
+tx_recv_interactive.py, server_tx.py & selected_recv.py) need to be run
+with a broker that supports these features (for instance the qpidd broker)
+
+There is a test script that will run most of the examples. This script needs
+a broker to be running already as a prerequisite. As this script runs the
+transactional and selector requiring examples this broker must support these
+features.
+
+For example:
+    qpidd --queue-patterns '.*' &
+    PATH=.:$PATH python -m unittest -v
+run from within the examples directory
 
 Note: For builds that include SASL support via the cyrus sasl library,
 those examples that accept incoming connections may require some SASL
diff --git a/python/examples/abstract_server.py b/python/examples/abstract_server.py
index 6a7e312..e0e3eb7 100755
--- a/python/examples/abstract_server.py
+++ b/python/examples/abstract_server.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,8 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
-
 from proton_server import Server
 
 
diff --git a/python/examples/broker.py b/python/examples/broker.py
index b47c636..0f2e889 100755
--- a/python/examples/broker.py
+++ b/python/examples/broker.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -22,8 +22,6 @@
 import optparse
 import uuid
 
-import unittest
-
 from proton import Endpoint
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
diff --git a/python/examples/client.py b/python/examples/client.py
index b149040..19f7edc 100755
--- a/python/examples/client.py
+++ b/python/examples/client.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,11 +18,10 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
-from proton.reactor import Container, DynamicNodeProperties
+from proton.reactor import Container
 
 
 class Client(MessagingHandler):
diff --git a/python/examples/client_http.py b/python/examples/client_http.py
index add9420..3f76aea 100755
--- a/python/examples/client_http.py
+++ b/python/examples/client_http.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import tornado.ioloop
 import tornado.web
 from tornado.gen import coroutine
diff --git a/python/examples/colour_send.py b/python/examples/colour_send.py
index 170f227..e04d7e1 100755
--- a/python/examples/colour_send.py
+++ b/python/examples/colour_send.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
diff --git a/python/examples/db_common.py b/python/examples/db_common.py
index 7d5c9b7..bd598de 100755
--- a/python/examples/db_common.py
+++ b/python/examples/db_common.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,12 +18,9 @@
 # under the License.
 #
 
-try:
-    import Queue
-except ImportError:
-    import queue as Queue
 
 import sqlite3
+import queue
 import threading
 
 
@@ -31,7 +28,7 @@
     def __init__(self, db, injector):
         self.db = db
         self.injector = injector
-        self.tasks = Queue.Queue()
+        self.tasks = queue.Queue()
         self.position = None
         self.pending_events = []
         self.running = True
@@ -111,7 +108,7 @@
                     while True:
                         f(conn)
                         f = self.tasks.get(False)
-                except Queue.Empty:
+                except queue.Empty:
                     pass
                 conn.commit()
                 for event in self.pending_events:
diff --git a/python/examples/db_ctrl.py b/python/examples/db_ctrl.py
index a263f96..8b5d4c3 100755
--- a/python/examples/db_ctrl.py
+++ b/python/examples/db_ctrl.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import sqlite3
 import sys
 
diff --git a/python/examples/db_recv.py b/python/examples/db_recv.py
index 8e293ce..7c95a2f 100755
--- a/python/examples/db_recv.py
+++ b/python/examples/db_recv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import ApplicationEvent, Container, EventInjector
diff --git a/python/examples/db_send.py b/python/examples/db_send.py
index c18f17f..577aa92 100755
--- a/python/examples/db_send.py
+++ b/python/examples/db_send.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,13 +18,8 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
-import time
-try:
-    import Queue
-except ImportError:
-    import queue as Queue
+import queue
 
 
 from proton import Message
@@ -41,7 +36,7 @@
         self.sent = 0
         self.confirmed = 0
         self.load_count = 0
-        self.records = Queue.Queue(maxsize=50)
+        self.records = queue.Queue(maxsize=50)
         self.target = count
         self.db = Db("src_db", EventInjector())
 
diff --git a/python/examples/direct_recv.py b/python/examples/direct_recv.py
index 50551fc..d85ef91 100755
--- a/python/examples/direct_recv.py
+++ b/python/examples/direct_recv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
diff --git a/python/examples/direct_send.py b/python/examples/direct_send.py
index 762d0cb..2e08904 100755
--- a/python/examples/direct_send.py
+++ b/python/examples/direct_send.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
diff --git a/python/examples/helloworld.py b/python/examples/helloworld.py
index 4e2adc9..fef5092 100755
--- a/python/examples/helloworld.py
+++ b/python/examples/helloworld.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
diff --git a/python/examples/helloworld_blocking.py b/python/examples/helloworld_blocking.py
index fb260d5..a5e5fb0 100755
--- a/python/examples/helloworld_blocking.py
+++ b/python/examples/helloworld_blocking.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,10 +18,8 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton import Message
 from proton.utils import BlockingConnection
-from proton.handlers import IncomingMessageHandler
 
 conn = BlockingConnection("localhost:5672")
 receiver = conn.create_receiver("examples")
diff --git a/python/examples/helloworld_direct.py b/python/examples/helloworld_direct.py
index 4218b53..65c0d72 100755
--- a/python/examples/helloworld_direct.py
+++ b/python/examples/helloworld_direct.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
diff --git a/python/examples/helloworld_direct_tornado.py b/python/examples/helloworld_direct_tornado.py
index 2b3bbd2..e1d2ae5 100755
--- a/python/examples/helloworld_direct_tornado.py
+++ b/python/examples/helloworld_direct_tornado.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton_tornado import Container
diff --git a/python/examples/helloworld_tornado.py b/python/examples/helloworld_tornado.py
index 5604b21..68f9e60 100755
--- a/python/examples/helloworld_tornado.py
+++ b/python/examples/helloworld_tornado.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton import Message
 from proton.handlers import MessagingHandler
 from proton_tornado import Container
diff --git a/python/examples/proton_server.py b/python/examples/proton_server.py
index 6dfd807..b588ea1 100755
--- a/python/examples/proton_server.py
+++ b/python/examples/proton_server.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/python/examples/proton_tornado.py b/python/examples/proton_tornado.py
index 55e8db8..a359b4c 100755
--- a/python/examples/proton_tornado.py
+++ b/python/examples/proton_tornado.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/python/examples/queue_browser.py b/python/examples/queue_browser.py
index 7f659f0..08b81a2 100755
--- a/python/examples/queue_browser.py
+++ b/python/examples/queue_browser.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton.reactor import Container, Copy
 from proton.handlers import MessagingHandler
 
diff --git a/python/examples/recurring_timer.py b/python/examples/recurring_timer.py
index 58f3ffd..55fbb26 100755
--- a/python/examples/recurring_timer.py
+++ b/python/examples/recurring_timer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton.reactor import Container, Handler
 
 
diff --git a/python/examples/recurring_timer_tornado.py b/python/examples/recurring_timer_tornado.py
index ff4c078..1d9bff4 100755
--- a/python/examples/recurring_timer_tornado.py
+++ b/python/examples/recurring_timer_tornado.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton.reactor import Handler
 from proton_tornado import Container
 
diff --git a/python/examples/selected_recv.py b/python/examples/selected_recv.py
index 43b576b..5d8b374 100755
--- a/python/examples/selected_recv.py
+++ b/python/examples/selected_recv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
 from proton import Url
 from proton.reactor import Container, Selector
diff --git a/python/examples/server.py b/python/examples/server.py
index eb0d66e..aad5504 100755
--- a/python/examples/server.py
+++ b/python/examples/server.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import optparse
 from proton import Message, Url
 from proton.handlers import MessagingHandler
diff --git a/python/examples/server_direct.py b/python/examples/server_direct.py
index 8cc7d9c..16496fa 100755
--- a/python/examples/server_direct.py
+++ b/python/examples/server_direct.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,8 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
-
 import uuid
 from proton import Message
 from proton.handlers import MessagingHandler
diff --git a/python/examples/server_tx.py b/python/examples/server_tx.py
index 731f9eb..7a2b9f2 100755
--- a/python/examples/server_tx.py
+++ b/python/examples/server_tx.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 from proton import Message
 from proton.reactor import Container
 from proton.handlers import MessagingHandler, TransactionHandler
diff --git a/python/examples/simple_recv.py b/python/examples/simple_recv.py
index 52724a3..f55dfa2 100755
--- a/python/examples/simple_recv.py
+++ b/python/examples/simple_recv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import optparse
 from proton.handlers import MessagingHandler
 from proton.reactor import Container
diff --git a/python/examples/simple_send.py b/python/examples/simple_send.py
index 1d36517..f078c12 100755
--- a/python/examples/simple_send.py
+++ b/python/examples/simple_send.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
 from proton import Message
 from proton.handlers import MessagingHandler
diff --git a/python/examples/sync_client.py b/python/examples/sync_client.py
index 9a395ae..3b6d8d3 100755
--- a/python/examples/sync_client.py
+++ b/python/examples/sync_client.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -23,13 +23,9 @@
 (also known as RPC or Remote Procedure Call) using proton.
 
 """
-from __future__ import print_function, unicode_literals
-
 import optparse
-from proton import Message, Url, ConnectionException, Timeout
+from proton import Message, Url
 from proton.utils import SyncRequestResponse, BlockingConnection
-from proton.handlers import IncomingMessageHandler
-import sys
 
 parser = optparse.OptionParser(usage="usage: %prog [options]",
                                description="Send requests to the supplied address and print responses.")
diff --git a/python/examples/test_examples.py b/python/examples/test_examples.py
index c40bf1a..51974cc 100644
--- a/python/examples/test_examples.py
+++ b/python/examples/test_examples.py
@@ -29,37 +29,21 @@
     def __init__(self, args, **kwargs):
         super(Popen, self).\
             __init__(args,
+                     shell=False,
                      stderr=subprocess.STDOUT,
                      stdout=subprocess.PIPE,
                      universal_newlines=True, **kwargs)
 
-    # For Python 2 compatibility add context manager support to Popen if it's not there
-    if not hasattr(subprocess.Popen, '__enter__'):
-        def __enter__(self):
-            return self
 
-    # For Python 2 compatibility add context manager support to Popen if it's not there
-    if not hasattr(subprocess.Popen, '__exit__'):
-        def __exit__(self, exc_type, exc_val, exc_tb):
-            try:
-                if self.stdin:
-                    self.stdin.close()
-                if self.stdout:
-                    self.stdout.close()
-                if self.stderr:
-                    self.stderr.close()
-            finally:
-                self.wait()
-
-
-def remove_unicode_prefix(line):
-    return re.sub(r"u(['\"])", r"\1", line)
-
+# Like subprocess.run with our defaults but returning the Popen object
+def run(args, **kwargs):
+    p = Popen(args, **kwargs)
+    p.wait()
+    return p
 
 class ExamplesTest(unittest.TestCase):
     def test_helloworld(self, example="helloworld.py"):
-        with Popen([example]) as p:
-            p.wait()
+        with run([example]) as p:
             output = [l.strip() for l in p.stdout]
             self.assertEqual(output, ['Hello World!'])
 
@@ -77,19 +61,17 @@
 
     def test_simple_send_recv(self, recv='simple_recv.py', send='simple_send.py'):
         with Popen([recv]) as r:
-            with Popen([send]):
+            with run([send]):
                 pass
-            actual = [remove_unicode_prefix(l.strip()) for l in r.stdout]
-            expected_py2 = ["{'sequence': int32(%i)}" % (i + 1,) for i in range(100)]
-            expected_py3 = ["{'sequence': %i}" % (i + 1,) for i in range(100)]
-            self.assertIn(actual, [expected_py2, expected_py3])
+            actual = [l.strip() for l in r.stdout]
+            expected = ["{'sequence': %i}" % (i + 1,) for i in range(100)]
+            self.assertEqual(actual, expected)
 
     def test_client_server(self, client=['client.py'], server=['server.py'], sleep=0):
         with Popen(server) as s:
             if sleep:
                 time.sleep(sleep)
-            with Popen(client) as c:
-                c.wait()
+            with run(client) as c:
                 actual = [l.strip() for l in c.stdout]
                 inputs = ["Twas brillig, and the slithy toves",
                           "Did gire and gymble in the wabe.",
@@ -128,7 +110,7 @@
 
         # run send and recv
         with Popen(['db_recv.py', '-m', '100']) as r:
-            with Popen(['db_send.py', '-m', '100']):
+            with run(['db_send.py', '-m', '100']):
                 pass
             r.wait()
             # verify output of receive
@@ -137,10 +119,9 @@
             self.assertEqual(actual, expected)
 
         # verify state of databases
-        with Popen(['db_ctrl.py', 'list', './dst_db']) as v:
-            v.wait()
+        with run(['db_ctrl.py', 'list', './dst_db']) as v:
             expected = ["(%i, 'Message-%i')" % (i + 1, i + 1) for i in range(100)]
-            actual = [remove_unicode_prefix(l.strip()) for l in v.stdout]
+            actual = [l.strip() for l in v.stdout]
             self.assertEqual(actual, expected)
 
     def test_tx_send_tx_recv(self):
@@ -150,36 +131,31 @@
         self.maxDiff = None
         with Popen(['direct_recv.py', '-a', 'localhost:8888']) as r:
             time.sleep(0.5)
-            with Popen(['simple_send.py', '-a', 'localhost:8888']):
+            with run(['simple_send.py', '-a', 'localhost:8888']):
                 pass
             r.wait()
-            actual = [remove_unicode_prefix(l.strip()) for l in r.stdout]
-            expected_py2 = ["{'sequence': int32(%i)}" % (i + 1,) for i in range(100)]
-            expected_py3 = ["{'sequence': %i}" % (i + 1,) for i in range(100)]
-            self.assertIn(actual, [expected_py2, expected_py3])
+            actual = [l.strip() for l in r.stdout]
+            expected = ["{'sequence': %i}" % (i + 1,) for i in range(100)]
+            self.assertEqual(actual, expected)
 
     def test_direct_send_simple_recv(self):
         with Popen(['direct_send.py', '-a', 'localhost:8888']):
             time.sleep(0.5)
-            with Popen(['simple_recv.py', '-a', 'localhost:8888']) as r:
-                r.wait()
-                actual = [remove_unicode_prefix(l.strip()) for l in r.stdout]
-                expected_py2 = ["{'sequence': int32(%i)}" % (i + 1,) for i in range(100)]
-                expected_py3 = ["{'sequence': %i}" % (i + 1,) for i in range(100)]
-                self.assertIn(actual, [expected_py2, expected_py3])
+            with run(['simple_recv.py', '-a', 'localhost:8888']) as r:
+                actual = [l.strip() for l in r.stdout]
+                expected = ["{'sequence': %i}" % (i + 1,) for i in range(100)]
+                self.assertEqual(actual, expected)
 
     def test_selected_recv(self):
-        with Popen(['colour_send.py']):
+        with run(['colour_send.py']):
             pass
 
-        with Popen(['selected_recv.py', '-m', '50']) as r:
-            r.wait()
+        with run(['selected_recv.py', '-m', '50']) as r:
             actual = [l.strip() for l in r.stdout]
             expected = ["green %i" % (i + 1) for i in range(100) if i % 2 == 0]
             self.assertEqual(actual, expected)
 
-        with Popen(['simple_recv.py', '-m', '50']) as r:
-            r.wait()
+        with run(['simple_recv.py', '-m', '50']) as r:
             actual = [l.strip() for l in r.stdout]
             expected = ["red %i" % (i + 1) for i in range(100) if i % 2 == 1]
             self.assertEqual(actual, expected)
diff --git a/python/examples/tx_recv.py b/python/examples/tx_recv.py
index bea05ab..2e4a736 100755
--- a/python/examples/tx_recv.py
+++ b/python/examples/tx_recv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import optparse
 from proton import Url
 from proton.reactor import Container
diff --git a/python/examples/tx_recv_interactive.py b/python/examples/tx_recv_interactive.py
index 63bc76b..e7626be 100755
--- a/python/examples/tx_recv_interactive.py
+++ b/python/examples/tx_recv_interactive.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function
 import sys
 import threading
 from proton.reactor import ApplicationEvent, Container, EventInjector
diff --git a/python/examples/tx_send.py b/python/examples/tx_send.py
index 3d53be5..8ba6638 100755
--- a/python/examples/tx_send.py
+++ b/python/examples/tx_send.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,7 +18,6 @@
 # under the License.
 #
 
-from __future__ import print_function, unicode_literals
 import optparse
 from proton import Message, Url
 from proton.reactor import Container