asyncio

namanviz
Hello
The below code snippet is from an example from git.
*******************************************************************************************************************
def on_ticks(ws, ticks):
logging.info("Ticks: {}".format(ticks))


def on_connect(ws, response):
ws.subscribe([13613826])

ws.set_mode(ws.MODE_FULL, [13613826])

def on_close(ws, code, reason):

ws.stop()

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

# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()

*******************************************************************************************************************


Can anyone advise on how to use asyncio for assigning callback 'kws.on_connect = on_connect'

Basically I am looking for something like this
async with kite_trade_socket(client_id, api_id, etc....) as ws:
***here I perform other async calls, and probably do not disturb the main thread****

I have tried few things but they don't seem to work
Thank you and Happy Diwali.
  • namanviz
    @sujith, can you please share any suggestion on the above query?
    Thanks.
  • sujith
    You can check out this thread.
  • namanviz
    Thank you Sujith,
    but the discussions on the provided thread did not help.
  • malay
    I realize; I am more than one year late on this. But posting just in case some one else also stumble upon this.
    I have just started exploring asyncio. I think it's a nice pattern and have advantages over multi threading.

    This project https://github.com/ranjanrak/async-ticker looks very promising. But if Zerodha has an official client that work with async/await or admins/others have any other suggestion; I would love to learn.
Sign In or Register to comment.