|
@@ -17,7 +17,6 @@ from sentry.utils.concurrent import (
|
|
|
)
|
|
|
|
|
|
|
|
|
-@pytest.mark.skipif(sys.version_info[0] == 3, reason="TODO(python3): stalls on python3")
|
|
|
def test_execute():
|
|
|
assert execute(_thread.get_ident).result() != _thread.get_ident()
|
|
|
|
|
@@ -108,9 +107,25 @@ def test_timed_future_success():
|
|
|
future.set_result(None)
|
|
|
assert future.get_timing() == (1.0, 2.0)
|
|
|
|
|
|
- with timestamp(3.0):
|
|
|
- future.set_result(None)
|
|
|
- assert future.get_timing() == (1.0, 3.0)
|
|
|
+
|
|
|
+@pytest.mark.skipif(sys.version_info[:2] < (3, 8), reason="doesn't apply to this python version")
|
|
|
+def test_time_is_not_overwritten_if_fail_to_set_result():
|
|
|
+ future = TimedFuture()
|
|
|
+
|
|
|
+ with timestamp(1.0):
|
|
|
+ future.set_running_or_notify_cancel()
|
|
|
+ future.set_result(1)
|
|
|
+ assert future.get_timing() == (1.0, 1.0)
|
|
|
+
|
|
|
+ from concurrent.futures import InvalidStateError
|
|
|
+
|
|
|
+ with timestamp(2.0):
|
|
|
+ try:
|
|
|
+ future.set_result(1)
|
|
|
+ except InvalidStateError:
|
|
|
+ pass
|
|
|
+
|
|
|
+ assert future.get_timing() == (1.0, 1.0)
|
|
|
|
|
|
|
|
|
def test_timed_future_error():
|
|
@@ -125,10 +140,6 @@ def test_timed_future_error():
|
|
|
future.set_exception(None)
|
|
|
assert future.get_timing() == (1.0, 2.0)
|
|
|
|
|
|
- with timestamp(3.0):
|
|
|
- future.set_exception(None)
|
|
|
- assert future.get_timing() == (1.0, 3.0)
|
|
|
-
|
|
|
|
|
|
def test_timed_future_cancel():
|
|
|
future = TimedFuture()
|