|
24 | 24 |
|
25 | 25 | from cassandra.cluster import Cluster, Session |
26 | 26 | from cassandra.connection import (Connection, HEADER_DIRECTION_TO_CLIENT, ProtocolError, |
27 | | - locally_supported_compressions, ConnectionHeartbeat, _Frame) |
| 27 | + locally_supported_compressions, ConnectionHeartbeat, _Frame, Timer, TimerManager) |
28 | 28 | from cassandra.marshal import uint8_pack, uint32_pack, int32_pack |
29 | 29 | from cassandra.protocol import (write_stringmultimap, write_int, write_string, |
30 | 30 | SupportedMessage, ProtocolHandler) |
@@ -413,3 +413,25 @@ def send_msg(msg, req_id, msg_callback): |
413 | 413 | self.assertIsInstance(exc, Exception) |
414 | 414 | self.assertEqual(exc.args, Exception('Connection heartbeat failure').args) |
415 | 415 | holder.return_connection.assert_has_calls([call(connection)] * get_holders.call_count) |
| 416 | + |
| 417 | + |
| 418 | +class TimerTest(unittest.TestCase): |
| 419 | + |
| 420 | + def test_timer_collision(self): |
| 421 | + # simple test demonstrating #466 |
| 422 | + def f1(): |
| 423 | + pass |
| 424 | + |
| 425 | + def f2(): |
| 426 | + pass |
| 427 | + |
| 428 | + # same timeout, comparison will defer to the Timer object itself |
| 429 | + t1 = Timer(0, f1) |
| 430 | + t2 = Timer(0, f2) |
| 431 | + t2.end = t1.end |
| 432 | + |
| 433 | + tm = TimerManager() |
| 434 | + tm.add_timer(t1) |
| 435 | + tm.add_timer(t2) |
| 436 | + # Prior to $466: "TypeError: unorderable types: Timer() < Timer()" |
| 437 | + tm.service_timeouts() |
0 commit comments