You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2019/02/25 18:40:22 UTC

[qpid-proton] 05/06: PROTON-1992: [Python] Give on_timer_task event a valid container - Fixes a problem with dispatch unit tests

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 46979cfe2872eb2bc7f48a2d8ff5a9ee4a4b414e
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Jan 23 00:13:02 2019 -0500

    PROTON-1992: [Python] Give on_timer_task event a valid container
    - Fixes a problem with dispatch unit tests
---
 python/proton/_reactor.py            |  8 ++++++--
 python/tests/proton_tests/reactor.py | 14 ++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/python/proton/_reactor.py b/python/proton/_reactor.py
index 6cf5305..993c177 100644
--- a/python/proton/_reactor.py
+++ b/python/proton/_reactor.py
@@ -19,7 +19,7 @@
 
 from __future__ import absolute_import
 
-from functools import total_ordering
+#from functools import total_ordering
 import heapq
 import json
 import logging
@@ -59,7 +59,7 @@ def _generate_uuid():
 def _now():
     return time.time()
 
-@total_ordering
+#@total_ordering
 class Task(object):
 
     def __init__(self, reactor, deadline, handler):
@@ -78,6 +78,10 @@ class Task(object):
     def handler(self):
         return self._handler
 
+    @property
+    def container(self):
+        return self._reactor
+
 class TimerSelectable(Selectable):
 
     def __init__(self, reactor, collector):
diff --git a/python/tests/proton_tests/reactor.py b/python/tests/proton_tests/reactor.py
index 923af2d..0e80e49 100644
--- a/python/tests/proton_tests/reactor.py
+++ b/python/tests/proton_tests/reactor.py
@@ -191,6 +191,20 @@ class ExceptionTest(Test):
         except Barf:
             pass
 
+    def test_schedule_event(self):
+        class Nothing:
+            def __init__(self, p):
+                self.parent = p
+
+            results = []
+            def on_timer_task(self, event):
+                self.parent.triggered = True
+                assert event.context == self.parent.task
+                assert event.container == self.parent.container
+        self.task = self.container.schedule(0, Nothing(self))
+        self.container.run()
+        assert self.triggered == True
+
     def test_schedule_many_nothings(self):
         class Nothing:
             results = []


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org