Running class KiteTicker as a thread gives "builtins.ValueError: signal only works in main thread"

lifegreat
My main program is calling class KiteTicker (like in example from https://kite.trade/docs/pykiteconnect/v3/ ) . It runs fine when I call it normally, however when I call class KiteTicker as a thread I get the below error (interestingly after the error (warning?!) the ticks are flowing normally).
.....handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
builtins.ValueError: signal only works in main thread

[{'tradable': True, 'mode': 'full', 'instrument_token': 12247298, 'last_price': 12354.3, ......//......, {'quantity': 150, 'price': 12354.8, 'orders': 1}]}}]
Can I not run KiteTicker as a thread? How can I get rid of this annoying error?
  • lifegreat
    I accidentally discovered the solution and its a simple fix.
    I missed parenthesis while creating thread and that gave me a nightmare.
    t1 = threading.Thread(target=KiteTicker) caused the issue and t1 = threading.Thread(target=KiteTicker()) fixed it
  • lifegreat
    just realized that is not a real fix.. when I put the parenthesis the actual class gets called while creating the thread itself and since KiteTicker class is a web socket nothing after that runs.
    so to run further threads I should run it like
    t1 = threading.Thread(target=KiteTicker)
    t1.start()
    but that leaves me the error mentioned in the initial post - kind of a dead lock scenario

    So my question is still open and any advice from anyone who faced this will be appreciated.
  • lifegreat
    it seems like this is a bug at the python level bugs.python.org/issue38904
    I am working towards a workaround; will post if I can figure out anything.
  • y_sravan
    you can start kite ticker in threaded with kws.connect(threaded=True)
  • lifegreat
    This helped. Thanks a lot.
This discussion has been closed.