Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Can't stop reactor that isn't running.

    Python SDK
    3
    5
    28
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kiran1808 last edited by

      I'm trying to get the ltp using websocket, and when i try to close the program in between using ctrl+c, i get errors "Can't stop reactor that isn't running", how to automatically exit the program after printing LTP only once?

      def on_tick(ws, tick):
      for i in tick:
      for j, k in i.items():
      if j == 'ltp':
      print(k)
      #how to exit here?

      S 1 Reply Last reply Reply Quote 0
      • S
        Surya 1 @kiran1808 last edited by

        @kiran1808

        you can use on_close

        def on_close(ws, code, reason):
            ws.stop()
        
        K 1 Reply Last reply Reply Quote 0
        • K
          kiran1808 @Surya 1 last edited by

          @rajanprabu that doesnt work:
          def on_tick(ws, tick):
          for i in tick:
          for j, k in i.items():
          if j == 'ltp':
          print(k)
          on_close(WS,'S562xxxx','test_stop')

          S 1 Reply Last reply Reply Quote 0
          • S
            Surya 1 @kiran1808 last edited by

            @kiran1808

            If I remember correct code is the token number of the scrip that you subscribed.

            1 Reply Last reply Reply Quote 0
            • James Bond
              James Bond last edited by James Bond

              @kiran1808 said in Can't stop reactor that isn't running.:

              how to automatically exit the program after printing LTP only once?

              If your sole objective is to print LTP once, then you should use ltpData function.

              obj.ltpData('exchange', 'tradingsymbol', token)
              

              It prints LTP only once.

              “Bond. James Bond.”

              1 Reply Last reply Reply Quote 0
              • First post
                Last post