PROTON-1709: [Python] Fix ApplicationEvent to avoid always creating a new EventType
- ApplicationEvent memoizes EventTypes created so it only creates one for any one
  typename string.
- ApplicationEvent accepts EventType as its first parameter so application can create
  their own EventType.
diff --git a/python/proton/_reactor.py b/python/proton/_reactor.py
index 828e5d2..c93b55d 100644
--- a/python/proton/_reactor.py
+++ b/python/proton/_reactor.py
@@ -453,8 +453,18 @@
     :type subject: any
     """
 
+    TYPES = {}
+
     def __init__(self, typename, connection=None, session=None, link=None, delivery=None, subject=None):
-        super(ApplicationEvent, self).__init__(EventType(typename))
+        if isinstance(typename, EventType):
+            eventtype = typename
+        else:
+            try:
+                eventtype = self.TYPES[typename]
+            except KeyError:
+                eventtype =  EventType(typename)
+                self.TYPES[typename] = eventtype
+        super(ApplicationEvent, self).__init__(eventtype)
         self.clazz = PN_PYREF
         self.connection = connection
         self.session = session