Hi everyone,
I like to implement a function that uses the "search" function of the package refinitiv.dataplatform (rdp) whenever it is called. However, when I run such a function, python always gets freezed without posting an error message. The strange thing is that when I run the function in debug mode, it works fine.
Here is a minimal example:
import refinitiv.dataplatform as rdp Name="ADIDAS" def getRelevantCDAXProducts(Name): RDP_LOGIN = "<login>" RDP_PASSWORD = "<password>" APP_KEY = "<app_key>" session = rdp.open_platform_session( APP_KEY, rdp.GrantPassword( username = RDP_LOGIN, password = RDP_PASSWORD ) ) searchResults=rdp.search(view = rdp.SearchViews.EquityQuotes,query=Name) return searchResults results=getRelevantCDAXProducts(Name)
Has anybody an idea why this issue occurs? If not, I would be very grateful if someone would at least try to run the minimal example to see what happens ("please note that you have to add your credentials"). It would be interesting to see whether this is a general problem or not.
Thank you very much!
Hi @Eikon10
I changed your application a little - you don't want to attempt to open the session over and over. That is, you don't need to open the session every time you search. Once opened, you can make as many calls while the session has been opened.
import refinitiv.dataplatform as rdp RDP_LOGIN = "<login>" RDP_PASSWORD = "<password>" APP_KEY = "<appkey>" session = rdp.open_platform_session( APP_KEY, rdp.GrantPassword( username = RDP_LOGIN, password = RDP_PASSWORD ) ) def getRelevantCDAXProducts(Name): searchResults=rdp.search( view=rdp.SearchViews.EquityQuotes, query=Name ) return searchResults
Now you can simply call your function:
Name="ADIDAS" results=getRelevantCDAXProducts(Name) results
Note: I did the following in a simple Jupyter notebook but the same applies to a standard Python application.
I do not reproduce the behavior you describe. On my end the function returns dataframe with the results of the search as expected. On a side note I should say that opening RDP session inside the function, which you intend to call repeatedly, is not a good practice. The good practice is to open RDP session once through the lifetime of your application. But despite not following good practice for opening the session, your code works fine on my end.
Thank you very much for your answers! Your are right, opening the session within the function is bad programming style, I changed that. Unfortunately, this did not solve my issue.
However, since the code worked in your case, I set up a new minimal virtual environment and then it worked well. There might be some conflicts with other packages that explain these conflicts.