Indian-Algorithmic-Trading-Community / DhanHQ-Ticker-py

The Unofficial Python Websocket Client For Communicating With The Dhan API.
https://indian-algorithmic-trading-community.github.io/DhanHQ-Ticker-py/
Apache License 2.0
34 stars 21 forks source link

AttributeError: 'DhanTicker' object has no attribute '_loop' #1

Closed shikharvaish28 closed 7 months ago

shikharvaish28 commented 8 months ago

Hello, I am using the login_with_credentials_ticker.py file & facing this error. How can I resolve it?

/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/bin/python /Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/main.py 
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1344, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1319, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1365, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1314, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1074, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1018, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1460, in connect
    self.sock = self._context.wrap_socket(self.sock,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 455, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1046, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1317, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/main.py", line 29, in <module>
    ticker = DhanTicker(
             ^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/dhanhq_ticker_py/ticker.py", line 769, in __init__
    fetch_and_save_latest_dhan_master_scrip_feather()
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/dhanhq_ticker_py/utils.py", line 992, in fetch_and_save_latest_dhan_master_scrip_feather
    pl.read_csv(MASTER_SCRIP_CSV_URL).select(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/polars/utils/deprecation.py", line 136, in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/polars/utils/deprecation.py", line 136, in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/polars/utils/deprecation.py", line 136, in wrapper
    return function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/polars/io/csv/functions.py", line 392, in read_csv
    with _prepare_file_arg(
         ^^^^^^^^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/polars/io/_utils.py", line 163, in _prepare_file_arg
    return _process_file_url(file, encoding_str)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/polars/io/_utils.py", line 233, in _process_file_url
    with urlopen(path) as f:
         ^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 515, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 532, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1392, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1347, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>
Exception ignored in: <function DhanTicker.__del__ at 0x1051b1580>
Traceback (most recent call last):
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/dhanhq_ticker_py/ticker.py", line 757, in __del__
    self._graceful_exit()
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/dhanhq_ticker_py/ticker.py", line 852, in _graceful_exit
    self.stop()
  File "/Users/prekshajagetiya/Downloads/phoenix_project/test_ticker/.venv/lib/python3.12/site-packages/dhanhq_ticker_py/ticker.py", line 1021, in stop
    if self._loop.is_running():
       ^^^^^^^^^^
AttributeError: 'DhanTicker' object has no attribute '_loop'
shikharvaish28 commented 7 months ago

@ShabbirHasan1 @MooneDrJune please have a look whenever you are available

ShabbirHasan1 commented 7 months ago

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)

A prompt Google search would suggest you that your system's SSL certificates may be outdated. It is advisable to update your SSL certificate using PIP.

image

https://stackoverflow.com/questions/50236117/scraping-ssl-certificate-verify-failed-error-for-http-en-wikipedia-org

https://support.chainstack.com/hc/en-us/articles/9117198436249-Common-SSL-Issues-on-Python-and-How-to-Fix-it