Refinitiv.dataplatform "search" get's stuck when called inside a function

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!
Best Answer
-
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 searchResultsNow you can simply call your function:
Name="ADIDAS"
results=getRelevantCDAXProducts(Name)
resultsNote: I did the following in a simple Jupyter notebook but the same applies to a standard Python application.
0
Answers
-
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.
0 -
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.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 37 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 697 Datastream
- 1.5K DSS
- 632 Eikon COM
- 5.2K Eikon Data APIs
- 12 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 4 Trading API
- 2.9K Elektron
- 1.4K EMA
- 256 ETA
- 563 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 281 Open PermID
- 46 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 749 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 123 Open DACS
- 1.1K RFA
- 107 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 96 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛