Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

avatar image
Question by michael-r.meyer · Aug 31, 2020 at 08:41 PM · eikoneikon-data-apiworkspacepythonworkspace-data-apirefinitiv-dataplatform-eikonapierror

I am receiving the following error message after I register my app with reuters through the python API: AttributeError: 'NoneType' object has no attribute 'status_code' ... Has anyone had any experience with this error and how to fix it?

People who like this

0 Show 3
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
michael-r.meyer · Aug 31, 2020 at 08:42 PM 0
Share

Error Message:

AttributeError: 'NoneType' object has no attribute 'status_code'

avatar image
michael-r.meyer · Sep 01, 2020 at 10:08 AM 0
Share

The eikon version is 1.1.5

Python is 3.6

The lines of code that produce this error is:

import eikon as eik

eik.set_app_key('xxxxxxxxxxxxxx')

heads = eik.get_news_headlines('AAPL.O',count = 1)

error here ---^

avatar image
michael-r.meyer · Sep 01, 2020 at 02:36 PM 0
Share

Running this code with logger:

  1. import logging
  2. import eikon as ek
  3. print(ek.__version__)
  4. ek.set_app_key('<app_key>')
  5. ek.set_log_level(1)
  6. ek.get_news_headlines("AAPL.O",count=10)

I get the following error:

2020-09-01 10:34:56,339 P[4776] [MainThread 5192] HTTP request failed: RuntimeError('read() called while another coroutine is already waiting for incoming data',)

9 Replies

  • Sort: 
avatar image
Best Answer
Answer by Antonios.Antoniadis · Sep 03, 2020 at 12:16 PM

Hi, not sure if I should open a separate thread, however I have also been getting exactly the same error message. I am using the 1.1.5 Eikon Data API version. I also tried the http3==0.6 workaround suggested in the post above without any luck. Is there an alternative workaround? Would updating to Python 3.7 fix this issue?

Thank you.

Comment

People who like this

0 Show 5 · 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
REFINITIV
umer.nalla ♦♦ · Sep 03, 2020 at 12:30 PM 0
Share

Hi @Antonios.Antoniadis

I have been advised by the RDP Dev team that they were able to reproduce what appears to be the same issue (i.e. same error message etc) with Python 3.6 - but could not be reproduced with 3.7 and also that version 1.1.5 of the Eikon library has been tested + qualified with Python 3.7 (but not 3.6)

Therefore, if you are able to test with v3.7 please do so.

avatar image
Antonios.Antoniadis umer.nalla ♦♦ · Sep 03, 2020 at 01:27 PM 0
Share

Hi, thanks for getting back to me. I just checked this internally and our IT policy prevents us from moving to Python 3.7 at least for another year. Could this fix be applied to Python 3.6?

avatar image
REFINITIV
Alex Putkov.1 ♦♦ · Sep 15, 2020 at 12:24 PM 0
Share

@Antonios.Antoniadis

Eikon Data APIs Python library v1.1.6.post2 is now available from PyPI. We believe this version of the library addresses various connection problems some users experienced with Eikon Data APIs Python library v1.1.5. Could you update the version of Eikon Data APIs Python library on your machine to v1.1.6.post2 and reply back on this thread if it helped?

avatar image
Antonios.Antoniadis Alex Putkov.1 ♦♦ · Sep 16, 2020 at 02:33 PM 0
Share

Thanks, looks like this has been resolved on my side.

avatar image
michael-r.meyer · Sep 23, 2020 at 12:32 PM 0
Share

When I upgraded to Python 3.7+ issue with current library was resolved.

avatar image
REFINITIV
Answer by Alex Putkov.1 · Aug 31, 2020 at 10:43 PM

Would you mind including the line of code that raises this exception? Or even better include the full trace.

Comment

People who like this

0 Show 0 · 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
REFINITIV
Answer by wasin.w · Sep 01, 2020 at 03:11 AM

Hello @michael-r.meyer

Could you please also let us know the version of Eikon data API that you are using? You can check the version dynamically via the following statement:

import eikon as ek
ek.__version__
Comment

People who like this

0 Show 0 · 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
REFINITIV
Answer by umer.nalla · Sep 01, 2020 at 09:20 AM

Hi @michael-r.meyer

Also, please confirm which version of Python you are using.


Comment

People who like this

0 Show 0 · 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
REFINITIV
Answer by Jirapongse · Sep 01, 2020 at 10:55 AM

@michael-r.meyer

Please try this code by setting the log level to 1.

import logging 
import eikon as ek 
print(ek.__version__) 
ek.set_app_key('<app_key>') 
ek.set_log_level(1) 
ek.get_news_headlines("AAPL.O",count=10)

You should see an exception. Please share the exception.


1598957623101.png (149.1 KiB)
Comment

People who like this

0 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
michael-r.meyer · Sep 01, 2020 at 11:46 AM 0
Share

Hi -

I set log level to 1 and get the following exception thrown:

1.1.5


2020-09-01 07:44:18,751 P[4776] [MainThread 5192] HTTP request failed: RuntimeError('read() called while another coroutine is already waiting for incoming data',)
avatar image
REFINITIV
Answer by umer.nalla · Sep 01, 2020 at 10:58 AM

Hi @michael-r.meyer

This may not be the exact same issue that you are facing - but an internal user had a very similar error message/ usage scenario and it was down to an incompatible version of http3 library when using Python 3.6

For that user, the following resolved the issue:

pip uninstall http3 
pip install http3==0.6

An alternative option would be to try Python 3.7 which the RDP library dev team advises they have validated and certified with this version.


Comment
michael-r.meyer

People who like this

1 Show 0 · 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
REFINITIV
Answer by Jirapongse · Sep 02, 2020 at 04:40 AM

@michael-r.meyer

I got the same error when using Python 3.6.8 and http3-0.6.7.

2020-09-02 11:26:44,511 P[19616] [MainThread 9404] HTTP request failed: RuntimeError('read() called while another coroutine is already waiting for incoming data',)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\venvs\3.6.8\lib\site-packages\eikon\news_request.py", line 121, in get_news_headlines
    result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)
  File "C:\venvs\3.6.8\lib\site-packages\eikon\json_requests.py", line 94, in send_json_request
    logger.debug('HTTP Response code: {}'.format(response.status_code))
AttributeError: 'NoneType' object has no attribute 'status_code'

You can try a workaround by using http3==0.6,as mentioned by my colleague.

pip uninstall http3 
pip install http3==0.6
Comment

People who like this

0 Show 0 · 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
Answer by michael-r.meyer · Sep 22, 2020 at 12:34 PM

Hi -

I found that installing Python 3.7 or above solved the problem. No error after that.


Thanks

Comment
umer.nalla

People who like this

1 Show 0 · 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
Answer by simon.garisch · Sep 24, 2020 at 06:23 AM

Untitled1


NoneType object has no attribute status_code¶

I had this exact same issue and tracked it back to a timeout in the nest_asyncio.py dependency.

In [3]:
import eikon as ek

ek.__version__
Out[3]:
'1.1.5'

This is just a helper function to demonstrate the source code we're looking at.

In [8]:
import inspect

def show_source_code(module, start_line, end_line):
    source = inspect.getsource(module)
    lines = source.split("\n")
    num_lines = len(lines)
    if start_line > num_lines:
        return ""
    if end_line > num_lines:
        end_line = num_lines
    print("\n".join(lines[start_line:end_line]))

Within the eikon package there is a 'json_requests.py' module containing the function 'send_json_request'.

This request gets a response from calling a http_request method. However, if this request fails it'll get response = None (say a timeout).

When try: logger.debug is called in the final line below it'll attempt to reference the status_code attribute of None and throw an attribute error.

In [21]:
show_source_code(ek.json_requests, 84, 94)

            # build the request
            udf_request = {'Entity': {'E': entity, 'W': data} }
            logger.debug('Request:{}'.format(udf_request))
            response = profile._desktop_session.http_request(url=profile.get_url(),
                                                             method="POST",
                                                             headers={'Content-Type': 'application/json',
                                                                      'x-tr-applicationid': profile.get_app_key()},
                                                             json=udf_request)
            try:
                logger.debug('HTTP Response code: {}'.format(response.status_code))
In [23]:
None.status_code

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-23-be7a3e11c091> in <module>
----> 1 None.status_code

AttributeError: 'NoneType' object has no attribute 'status_code'

This sent me on a bit of a hunt for the underlying issue... I'll spare you the steps inbetween, but I ended up having to fiddle with the timeout variable in the nest_asyncio.py dependency.

In [27]:
import nest_asyncio
In [32]:
show_source_code(nest_asyncio, 71, 74)

        timeout = 0 if ready or self._stopping \
            else min(max(0, scheduled[0]._when - now), 10) if scheduled \
            else None

If left unaltered then we'll end up with the issue you're seeing.

In [1]:
APP_KEY = "..."
In [2]:
import eikon as ek

ek.set_app_key(APP_KEY)
In [3]:
ek.get_news_headlines("AAPL.O",count=10)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-4b16f70155ba> in <module>
----> 1 ek.get_news_headlines("AAPL.O",count=10)

C:\Anaconda2\envs\py36\lib\site-packages\eikon\news_request.py in get_news_headlines(query, count, date_from, date_to, raw_output, debug)
    119         payload.update({
  
  'dateTo': to_datetime(date_to).isoformat()})
    120 
--> 121     result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)
    122 
    123     if raw_output:

C:\Anaconda2\envs\py36\lib\site-packages\eikon\json_requests.py in send_json_request(entity, payload, debug)
     92                                                              json=udf_request)
     93             try:
---> 94                 logger.debug('HTTP Response code: {}'.format(response.status_code))
     95                 logger.debug('HTTP Response: {}'.format(response.text))
     96             except UnicodeEncodeError as unicode_error:

AttributeError: 'NoneType' object has no attribute 'status_code'

And that's what I was seeing...

However, we can modify the code in nest_asyncio and it'll work. Yes, it's a hack, but it'll work until the devs clean things up.

I incremented the timeout as follows (by adding 3 extra lines at the end):

In [9]:
import inspect
import nest_asyncio

show_source_code(nest_asyncio, 71, 77)

        timeout = 0 if ready or self._stopping \
            else min(max(0, scheduled[0]._when - now), 10) if scheduled \
            else None
        if timeout is not None:
            if timeout > 0:
                timeout = 20

And if you try it again:

In [4]:
ek.get_news_headlines("AAPL.O",count=1)
Out[4]:
versionCreatedtextstoryIdsourceCode2020-09-23 19:53:50.8892020-09-24 06:05:51.489000+00:00Reuters Insider - The "no matter what" stocks:...urn:newsml: reuters.com:20200923:nRTV28VXrs:13NS:RTRS

Comment

People who like this

0 Show 0 · 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.

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 >
15 People are following this question.

Related Questions

How do I fix this error?

API Proxy not starting on Mac

refinitiv.dataplatform.errors.RDPError: Error code 1503| Backend request failed

Using Eikon API to get live data into a Python dataframe, where there is no RIC

Can't get quaterly data

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • 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
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges