Ejemplo n.º 1
0
    async def test_sends_heartbeat_on_test_request(self, zero_heartbeat_app):
        request_message = TestRequestMessage("test123")
        await zero_heartbeat_app.on_test_request(request_message)

        # Wait for separate 'send' tasks to complete
        tasks = asyncio.all_tasks()
        await asyncio.wait(tasks, timeout=0.1)

        zero_heartbeat_app.pipeline.send.assert_called_with(
            admin.HeartbeatMessage("test123"))
Ejemplo n.º 2
0
    async def send_heartbeat(self):
        """
        Send our own heartbeat to indicate that the pipeline is still responding.
        """
        logger.debug(f"{self.name}: Pipeline idle, sending heartbeat...")

        # Update timer immediately to avoid flooding the target with heartbeats.
        HeartbeatTimers.SEND.timestamp = datetime.utcnow()

        asyncio.create_task(self.send(admin.HeartbeatMessage())
                            )  # Don't need to block while heartbeat is sent
Ejemplo n.º 3
0
    async def on_test_request(self, message: FIXMessage) -> FIXMessage:
        """
        Send a HeartBeat message in response to a TestRequest received from the server.

        :param message: The TestRequest message. Should contain a TestReqID.
        """
        logger.debug(
            f"{self.name}: Sending heartbeat in response to request {message.TestReqID}."
        )
        # Don't need to block while heartbeat is sent
        asyncio.create_task(self.send(admin.HeartbeatMessage(str(message.TestReqID))))

        return message