Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Refinitiv Data Platform /
  • Refinitiv Data Platform Libraries /
avatar image
REFINITIV
Question by michaelearl0 · Jan 13 at 04:59 AM · python apistreaming pricerpd library

Asynio library errors when running rdp.StreamingPrices simple test

asynio library error once every several minutes(~4 mins)

Using Python v3.9.1. Latest RDP libraries via python -m pip install --upgrade refinitiv.dataplatform

The message is like this: (with DEBUG logging enabled)

2021-01-13 01:13:52,214 - websocket - ERROR - error from callback <bound method StreamConnection._ws_message of <OMMStreamConnection(WebSocket 0 - pricing, started daemon 140170804320000)>>: Non-thread-safe operation invoked on an event loop other than the current one
File "/home/originai/trader/originai/signal/refinitiv/refinitiv-env/lib/python3.6/site-packages/websocket/_app.py", line 344, in _callback
callback(*args)
File "/home/originai/trader/originai/signal/refinitiv/refinitiv-env/lib/python3.6/site-packages/refinitiv/dataplatform/delivery/stream/stream_connection.py", line 838, in _ws_message
self._on_messages(messages)
File "/home/originai/trader/originai/signal/refinitiv/refinitiv-env/lib/python3.6/site-packages/refinitiv/dataplatform/delivery/stream/omm_stream_connection.py", line 239, in _on_messages
self._process_response_message(message)

File "/home/originai/trader/originai/signal/refinitiv/refinitiv-env/lib/python3.6/site-packages/refinitiv/dataplatform/delivery/stream/omm_stream_connection.py", line 341, in _process_response_message
self._on_receive_login_message(result)
File "/home/originai/trader/originai/signal/refinitiv/refinitiv-env/lib/python3.6/site-packages/refinitiv/dataplatform/delivery/stream/stream_connection.py", line 671, in _on_receive_login_message
self._login_response_future.set_result(result)
File "/usr/lib/python3.6/asyncio/futures.py", line 298, in set_result
self._schedule_callbacks()
File "/usr/lib/python3.6/asyncio/futures.py", line 214, in _schedule_callbacks
self._loop.call_soon(callback, self)
File "/usr/lib/python3.6/asyncio/base_events.py", line 593, in call_soon
self._check_thread()
File "/usr/lib/python3.6/asyncio/base_events.py", line 632, in _check_thread
"Non-thread-safe operation invoked on an event loop other "
2021-01-13 01:14:07,449 - Session session.platform - Thread 140170804320000 | WebSocket 0 - pricing

People who like this

0 Show 2
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
umer.nalla ♦♦ · Jan 13 at 11:25 AM 0
Share

Hi @michael.earl

Are you able to post the code here or even a smaller snippet which recreates the issue?

Easiest would be if you can attach it as a .txt file.

avatar image
cychiang · Jan 13 at 03:25 PM 0
Share

Hi Umer,

I attached the code asyncio_test_20210113.txt

Please change the login credential to give it a try.

Thanks for taking a look!

asyncio-test-20210113.txt (1.5 KiB)

2 Replies

  • Sort: 
avatar image
REFINITIV
Answer by umer.nalla · Jan 13 at 05:00 PM

Hi @michael.earl / @cychiang

When I ran your snippet it crashed almost immediately after getting the first Refresh Messages.

However, if I replace the last line of code with something like:

while (True):
    asyncio.get_event_loop().run_until_complete(asyncio.sleep(120))

Then It ran fine for over 10 minutes without a problem.

Please let me know if the above works for you also.

I am not a Python expert so cannot explain why the above is ok and your alternative is not. I will refer this to the RDP Python library development team and hopefully, they will respond with an explanation.

Comment
cychiang

People who like this

1 Show 3 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
cychiang · Jan 13 at 05:59 PM 0
Share

Thank you Umer, I will use your method and keep it running for a day and report back.

avatar image
REFINITIV
umer.nalla ♦♦ cychiang · Jan 14 at 10:13 AM 0
Share

Note that I have been advised there is a bug in rdp library version 1.0.0a7.post1 with refreshing the access token every 4-5 minutes. I am still using version 1.0.0a7 and perhaps that is why it is working for me.

If the above-suggested code change fails for you, please run the 'pip list' command in a Python console and attach the output as .txt file in your reply.

You can confirm your RDP library version with:

import refinitiv.dataplatform as rdp
rdp.__version__
avatar image
cychiang umer.nalla ♦♦ · Jan 14 at 05:20 PM 0
Share

Hi Umer,

I am using 1.0.0a5 version.

pip_list.txt

The while loop method can not avoid the issue.

It still happened once every two~three minutes in my testing.

Thanks!

pip-list.txt (598 B)
avatar image
REFINITIV
Answer by umer.nalla · Jan 14 at 09:00 PM

Hi @cychiang

Thanks for the pip list, I have passed it onto the RDP Python dev team to examine.

In the meantime, if you are able to do so (ideally in a virtualenv), you could try out the version I am using on my PC v1.0.0a7 - available on PyPI - refinitiv-dataplatform · PyPI


Comment
cychiang

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
cychiang · Jan 18 at 05:00 PM 0
Share

Hi Umer,

I can confirm that after using v1.0.0a7, and python 3.9, your workaround can avoid the issue.

However, if I use .run_forever() the issue still happens, so I think there is still something wrong in the library. But I am fine with the workaround.

BTW, I found that v1.0.0a7 uses asyncio differently (e.g. asyncio.create_task) such that I can not keep using python3.6. I have to update to python 3.9, and it created some pain. I am afraid that other users might get hit by the same issue.

Thanks!

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
11 People are following this question.

Related Questions

Python RDP API does not use proxy server when connecting

How do I retrieve index constituents in RDP/Python

RDP in Python not connecting despite valid App Key

RDP authentication error

RDP Python API performance

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges