ic-py: TypeError: object of type 'NoneType' has no len()
When I run this code
from ic.client import Client
from ic.identity import Identity
from ic.agent import Agent
from ic.candid import encode, Types
import time
import schedule
import sys
# params is an array, return value is encoded bytes
# params = [{'type': Types.Nat, 'value': 10}]
# data = encode(params)
# Identity and Client are dependencies of Agent
iden = Identity() # creates a random keypair
client = Client() # creates a client to talk to the IC
# creates an agent, combination of client and identity
agent = Agent(iden, client)
def main():
backup(canister_id=sys.argv[1])
schedule.every(5).seconds.do(backup, canister_id=sys.argv[1])
while True:
schedule.run_pending()
time.sleep(1)
def backup(canister_id):
print(f"disburse completed at {time.ctime()}")
# query the NFT canister
# doesnt change after calling `shuffleAssets`
result = agent.update_raw(
canister_id, "disburse", encode([]))
print(result)
get the following error after a couple of iterations:
Traceback (most recent call last):
File "/home/moritz/.venv/bin/backup", line 8, in <module>
sys.exit(main())
File "/home/moritz/.venv/lib/python3.8/site-packages/state_backup/backup.py", line 25, in main
schedule.run_pending()
File "/home/moritz/.venv/lib/python3.8/site-packages/schedule/__init__.py", line 780, in run_pending
default_scheduler.run_pending()
File "/home/moritz/.venv/lib/python3.8/site-packages/schedule/__init__.py", line 100, in run_pending
self._run_job(job)
File "/home/moritz/.venv/lib/python3.8/site-packages/schedule/__init__.py", line 172, in _run_job
ret = job.run()
File "/home/moritz/.venv/lib/python3.8/site-packages/schedule/__init__.py", line 661, in run
ret = self.job_func()
File "/home/moritz/.venv/lib/python3.8/site-packages/state_backup/backup.py", line 33, in backup
result = agent.update_raw(
File "/home/moritz/.venv/lib/python3.8/site-packages/ic/agent.py", line 92, in update_raw
return decode(result)
File "/home/moritz/.venv/lib/python3.8/site-packages/ic/candid.py", line 1123, in decode
b = Pipe(data)
File "/home/moritz/.venv/lib/python3.8/site-packages/ic/candid.py", line 45, in __init__
self._view = buffer[0:len(buffer)]
TypeError: object of type 'NoneType' has no len()
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
I ran ur code about serveral minutes, but no error occured. Can you find a specific method to reproduce the issue?
Besides, what’s ur current version of ic-py.