-
Notifications
You must be signed in to change notification settings - Fork 91
Errors and the bot does not answer. (KeyError: (<pancaketrade.network.bsc.Network object at 0x7f3249d0b370>,)) #97
Comments
Hey there! This is why I kinda stopped developing this project, Python is really not that great for this type of stuff. It looks like some memoization (in-memory caching) is not happening properly but I have no idea why. I tried to re-install pancaketrade recently and I had to tinker a bunch with different dependencies version to make it run, and I still face issues sometimes. I'm currently working on a much better version written in Rust but it's not ready for public eyes yet and it will take a long time to finish with my current schedule and free time. |
What would be those versions of dependencies that work in a more stable way? Python 3.7, 3.8? Poetry? Docker? Or any other advice to make it work better? |
I used Python 3.9, poetry 1.5.1 (had to erase the poetry.lock file and re-generate it). I pinned the |
I already implemented the instructions you gave me and it keeps giving me an error. I'm trying to correct it using code interpreter, here are some of your suggestions:
Applying these fixes is beyond my knowledge, but maybe it will help you. In the meantime, I'm going to be studying Python so that one day I can develop my tools and/or be able to correct errors that arise. Greetings! |
That's a lot of chatGPT. The caching is handled by the cachetools library and I have no control over its logic. I can't try/catch the mechanism that is implemented in their decorator. I don't think this is a bug with pancaketrade to be honest. Try to upgrade the cachetools dependency maybe? The caching happens in-memory so there should not be a key in there that doesn't exist or something in that vein and all the checks happen in the decorator automatically, it's a "black box" |
I understand, now the second issue is how pancaketrade responds to the error in the cache. On the one hand, it does not send you a TG notification that an error occurred, on the other, it does not seek to restart the dependencies or only cachetools. This would be important to implement and also trying to update cachetools would not be bad either |
At the moment I cannot reproduce the issue so it's hard to test any solution. Like I said, I don't think I will update pancaketrade since I'm working on a replacement. It will take time for sure, and I might want to wait until the new alloy-rs replacement for ethers-rs comes out. |
It's okay, I understand now. I'm currently running it with pyhton 3.9.17 without any pyenv and it definitely works better. Even so, I will be looking forward to the new model of the bot. Greetings and thanks from Argentina! |
Hello genius!
First I want to thank you for the work you did. This is a very useful tool for people who operate in the defi space.
I dedicate myself more to trading than to programming, so understanding how this program works in depth is a bit difficult for me.
I already managed to make work and configure it without a problem, what happens to me now is that after running for a while, it remains frozen. When I look at the terminal I get the following error:
ERROR |Exception while handling an update
ERROR |(<pancaketrade.network.bsc.Network object at 0x7f3249d0b370>,)
ERROR |An uncaught error was raised while handling the error.
Traceback (most recent call last):
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 555, in process_update
handler.handle_update(update, self, check, context)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/ext/handler.py", line 198, in handle_update
return self.callback(update, context)
File "/home/morpheus/pancaketrade/pancaketrade/utils/generic.py", line 64, in wrapper_check_chat_id
return func(this, update, context, *args, **kwargs)
File "/home/morpheus/pancaketrade/pancaketrade/bot.py", line 163, in command_status
status, balance_value = self.get_token_status(token)
File "/home/morpheus/pancaketrade/pancaketrade/bot.py", line 313, in get_token_status
token_price, base_token_address = self.net.get_token_price(token_address=token.address)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/cachetools/decorators.py", line 26, in wrapper
v = func(*args, kwargs)
File "/home/morpheus/pancaketrade/pancaketrade/network/bsc.py", line 253, in get_token_price
return self.get_token_price_for_lp(token, base_token, ignore_poolsize=True), base_token_address
File "/home/morpheus/pancaketrade/pancaketrade/network/bsc.py", line 287, in get_token_price_for_lp
elif (base_amount / self.get_bnb_price()) / Decimal(1018) < self.min_pool_size_bnb and not ignore_poolsize:
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/cachetools/decorators.py", line 28, in wrapper
cache[k] = v
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/cachetools/ttl.py", line 87, in setitem
self.expire(time)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/cachetools/ttl.py", line 167, in expire
cache_delitem(self, curr.key)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/cachetools/cache.py", line 66, in delitem
del self.__data[key]
KeyError: (<pancaketrade.network.bsc.Network object at 0x7f3249d0b370>,)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 567, in process_update
self.dispatch_error(update, exc)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 810, in dispatch_error
callback(update, context)
File "/home/morpheus/pancaketrade/pancaketrade/bot.py", line 400, in error_handler
chat_message(update, context, text=f"⛔️ Exception while handling an update\n{context.error}", edit=False)
File "/home/morpheus/pancaketrade/pancaketrade/utils/generic.py", line 91, in chat_message
return context.bot.send_message(chat_id=update.effective_chat.id, text=text, reply_markup=reply_markup)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/bot.py", line 130, in decorator
result = func(*args, **kwargs)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/bot.py", line 522, in send_message
return self._message( # type: ignore[return-value]
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/ext/extbot.py", line 200, in _message
result = super()._message(
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/bot.py", line 336, in _message
result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs)
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/bot.py", line 295, in _post
return self.request.post(
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/utils/request.py", line 361, in post
result = self._request_wrapper(
File "/home/morpheus/pancaketrade/.venv/lib/python3.9/site-packages/telegram/utils/request.py", line 279, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Can't parse entities: unsupported start tag "pancaketrade.network.bsc.network" at byte offset 43
Any guidance on what may be happening and how to resolve it? I already tried to run it in Docker and it also freezes after a while.
Greetings!
The text was updated successfully, but these errors were encountered: