About RDP streaming event

Hi all, In my app I have used streaming to get the data and use asyncio to do the calculation process when got an event sometimes it's still do the refresh event process but it's got update event usually it's must finish the refresh event first then do the update event but in my case it's doesn't finish refresh event it swaps to update event. Is this normal? because from my understanding I must use await in my app to swap to other tasks but my app didn't use any of it. here below is example of my code

1637216616539.png

Tagged:

Best Answer

  • umer.nalla
    umer.nalla LSEG
    Answer ✓

    Hi @nuttanon.jitsamran

    I am not sure I fully understand your question.

    Also, I am not a Python expert so cannot confirm how the asycnio task will be actioned or shutdown etc - nor can I advise on general Python 'multi-threading'.

    The key point I am making is that you are dealing with live streaming data - so it is entirely possible to receive an update for an instrument before you have finished processing the Refresh.

    Depending on how long your Update related calculations take, it is also entirely possible that you could receive a further update, whilst you are still processing the previous update.

    For something like Java or C++, the developer could spawn off a worker thread to process the RefreshMsg leaving the main (API) thread to continue receiving and handling the Update - with some strategy to ensure that any subsequent update does not disrupt or corrupt any ongoing calculations on the same instrument still being performed on the Refresh or previous update.

    You need to redesign your code so that the calculations are not done in the callback (on_data_refresh, on_data_update). For example, rather than performing any Refresh or Update calculations in the callback function - you add data to a queue and return control back to the RDP library. You could then have a separate 'thread' processing the queue? Again - not a Python expert so not sure how appropriate this is?


Answers