raise error.ReactorNotRestartable()

UE6253
UE6253 edited August 2018 in Python client
Hi,
I am trying to use WebSockets example given on github but getting error -
raise error.ReactorNotRestartable()
What am I doing wrong ?

Tagged:
  • rakeshr
    @UE6253
    Are you trying to run on_tick thread multiple time?
    Can you paste your code here.
  • UE6253
    I am trying to post my code since last 4 hours but it keep on saying your comment will be shown after approval !!
  • UE6253
    attached is the code.. pl suggest
  • UE6253
    Rakesh, can you pl look into this and suggest ?
  • rakeshr
    @UE6253
    tokens = ['NSE:NCC', 'NSE:INFY']
    You need to use instrument_token instead of tradingsymbol, check it here.
  • UE6253
    I changed the tokens but getting now following error -

    calling KWS.connect
    finished kws connect process
    Exception in thread Thread-15:
    Traceback (most recent call last):
    File "C:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
    File "C:\ProgramData\Anaconda3\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1242, in run
    self.startRunning(installSignalHandlers=installSignalHandlers)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1222, in startRunning
    ReactorBase.startRunning(self)
    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\base.py", line 730, in startRunning
    raise error.ReactorNotRestartable()
    twisted.internet.error.ReactorNotRestartable
  • UE6253
    Above was on windows (spider). On my Linux box , it does nothing... no ticks printed and no error.
    Just prints msg before and after the connect() call.
  • rakeshr
    @UE6253
    You need to remove threaded=True from kws.connect( threaded=True), as i don't see you are implementing any external thread.
  • UE6253
    If I remove that, I get following error -


    File "", line 1, in
    runfile('D:/workspace_pyCharm/Test_Zerodha.py', wdir='D:/workspace_pyCharm')

    File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
    execfile(filename, namespace)

    File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

    File "D:/workspace_pyCharm/Test_Zerodha.py", line 67, in
    kws.connect()

    File "C:\ProgramData\Anaconda3\lib\site-packages\kiteconnect-3.7.4-py3.6.egg\kiteconnect\ticker.py", line 532, in connect
    reactor.run(**opts)

    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1242, in run
    self.startRunning(installSignalHandlers=installSignalHandlers)

    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1222, in startRunning
    ReactorBase.startRunning(self)

    File "C:\ProgramData\Anaconda3\lib\site-packages\twisted\internet\base.py", line 730, in startRunning
    raise error.ReactorNotRestartable()

    ReactorNotRestartable
  • rakeshr
    @UE6253
    I copy pasted your above code in my env, it's returning all subscribed ticks. Make sure, you are not calling, on_close method anywhere else.
    It can also your be local environement issue.Can you try above modified code in Linux and check it, again.
Sign In or Register to comment.