Unable to stream - ReactorNotRestartable error

rasumaya
rasumaya edited January 23 in Python client
I am unable to stream tick level data and keep getting ReactorNotRestartable error. I am able to pull historical data and have tested pretty much every API call without any problem except streaming tick data. Can you please help. below is my code.
from kiteconnect import KiteConnect
from kiteconnect import KiteTicker
import logging

request_token = open("request_token.txt",'r').read()
key_secret = open("api_key.txt",'r').read().split()
kite = KiteConnect(api_key=key_secret[0])
data = kite.generate_session(request_token, api_secret=key_secret[1])

#create KiteTicker object
kws = KiteTicker(key_secret[0],data["access_token"])

tokens = [738561, 5633]

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

def on_connect(ws,response):
# Callback on successful connect.
logging.debug("on connect: {}".format(response))
ws.subscribe(tokens)
#ws.set_mode(ws.MODE_FULL,tokens)

kws.on_ticks=on_ticks
kws.on_connect=on_connect
kws.connect()
#########################################################################################
Below is the error
Traceback (most recent call last):

File "<ipython-input-70-afaa4a2e484c>", line 19, in <module>
kws.connect()

File "C:\Users\User\Anaconda3\lib\site-packages\kiteconnect-3.8.0-py3.6.egg\kiteconnect\ticker.py", line 534, in connect
reactor.run(**opts)

File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\twisted\internet\base.py", line 1282, in run
self.startRunning(installSignalHandlers=installSignalHandlers)

File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\twisted\internet\base.py", line 1262, in startRunning
ReactorBase.startRunning(self)

File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\twisted\internet\base.py", line 765, in startRunning
raise error.ReactorNotRestartable()

ReactorNotRestartable
Sign In or Register to comment.