right, i just got the return statement out of the if statement lol thanks On Tuesday, 16 March 2021 at 21:11:36 UTC Tycho Andersen wrote:
> On Tue, Mar 16, 2021 at 01:45:34PM -0700, [email protected] wrote: > > I am trying to loop through different crypto prices with the api calls, > so > > i can keep track on my portfolio with the widget. > > > > It works sometimes, but at some point the widget just freezes and I have > to > > restart qtile. This may lead to the widget disappearing. > > > > Here is the code I put for the poll function: > > > > ``` > > def get_crypto(): > > cryptos = dict( > > btc="bitcoin", > > eth="ethereum", > > bnb="binancecoin", > > ada="cardano", > > cro="crypto-com-chain", > > nexo="nexo", > > cake="pancakeswap-token", > > bifi="beefy-finance", > > watch="yieldwatch", > > kebab="kebab-token", > > bdo="bdollar", > > salt="saltswap", > > ) > > > > try: > > cg = coingeckoapi() > > symbol = list(cryptos.keys())[datetime.datetime.now().minute % > > len(cryptos)] > > crypto = cryptos[symbol] > > > > price = cg.get_price( > > ids=crypto, vs_currencies="hkd", include_24hr_change="true" > > ) > > price, change = price[crypto]["hkd"], > > price[crypto]["hkd_24h_change"] > > if change > 0: > > change = "+" + str(round(change, 1)) + "%" > > return symbol.upper() + ":$" + str(price) + " " + change > > Here, you do not return anything. Python defaults to returning None if > nothing was explicitly returned. Presumably it stops when there are no > price changes. > > > except exception: > > return "error {}".format(crypto) > > > > ``` > > > > I think this is fairly straight forward and I set the time_interval to > 60. > > Any suggestions? thanks > > > > -- > > You received this message because you are subscribed to the Google > Groups "qtile-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/qtile-dev/3c2964b2-95c8-4566-a603-92271f320068n%40googlegroups.com > . > > -- You received this message because you are subscribed to the Google Groups "qtile-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/qtile-dev/a8a4aeaa-210e-4269-be71-59ac7601e792n%40googlegroups.com.
