KiteTicker Getting error.ReactorNotRestartable()

nitixa14
I am using kiteconnect3.
While running following code
#!python
from pprint import pprint

from kiteconnect import KiteTicker

kws = KiteTicker("API_KEY", "ACCESS_TOKEN")


def on_ticks(ws, ticks):
# Callback to receive ticks.
# logging.debug("Ticks: {}".format(ticks))
pprint(ticks)
# print(ticks)
print("\n")


def on_connect(ws, response):
# Callback on successful connect.
# Subscribe to a list of instrument_tokens (RELIANCE ad ACC here).
ws.subscribe([3050241, 177665])

# Set RELIANCE to tick in `full` mode.
ws.set_mode(ws.MODE_FULL, [3050241, 177665])


# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect

# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()
I am getting following error
File "/Applications/MAMP/htdocs/laptop/algoTradedt/Training Program files/kiteconnect series/lecture 2 get data/get data.py", line 63, in <module>
kws.connect()

File "/Users/Apple/opt/anaconda3/lib/python3.7/site-packages/kiteconnect/ticker.py", line 532, in connect
reactor.run(**opts)

File "/Users/Apple/opt/anaconda3/lib/python3.7/site-packages/twisted/internet/base.py", line 1282, in run
self.startRunning(installSignalHandlers=installSignalHandlers)

File "/Users/Apple/opt/anaconda3/lib/python3.7/site-packages/twisted/internet/base.py", line 1262, in startRunning
ReactorBase.startRunning(self)

File "/Users/Apple/opt/anaconda3/lib/python3.7/site-packages/twisted/internet/base.py", line 765, in startRunning
raise error.ReactorNotRestartable()

ReactorNotRestartable
I am using MacOsX. I have installed scrapy, twisted, kiteconnect.



How to solve this error?
  • rakeshr
    @nitixa14
    You can go through this thread.
  • nitixa14
    I executed same code using python idle.
    And i am getting following errors
    Warning (from warnings module):
    File "", line 0
    UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''. Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
    Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    So i go through https://pypi.python.org/pypi/service_identity this link
    and installed service_identity, which was already installed
    Here is what i got in terminal
    Requirement already satisfied: pycparser in /Users/Apple/opt/anaconda3/lib/python3.7/site-packages (from cffi!=1.11.3,>=1.8->cryptography->service_identity) (2.19)

    Then i executed code again and getting same error.
    The thread you suggested not helping much.
    I have checked instrument token too. It's correct token.
  • sujith
    A 403 means your session is expired. You need to create a new access token.
  • nitixa14
    I updated access token and it worked.
    I have executed same code in spyder.
    It worked for once. I tried second time and got same error ReactorNotRestartable().
    Is there anything that i need to install separately for Anaconda?
  • nitixa14
    When i restarts spyder again it works for once.
  • rakeshr
    @nitixa14
    It worked for once. I tried second time and got same error ReactorNotRestartable()
    Yeah, initial succesul run and then subsequent reactor failure issue is highiigted in this open git issue.
    So, until library resolves this issue, you may use the default python setup.
Sign In or Register to comment.