Anomaly while running the same piece of code in loop


#1

Hey,

I was running a simple code in an infinite loop. It ran as it should for 8 iterations but on 9th it gave a type error:

    "the JSON object must be str, not 'dict' "

I don’t get how the same piece of code runs well for 8 iterations but shows an error on 9th!?!

I have attached a picture as proof and also a piece of my code.
I await your response.

PS: The fourth last line in IMG_…214139.jpg is line 51.

IMG_20190520_214052|690x388


#2

@naruto.amigo30 In such cases, a print statement usually helps to see what response has been received. Try adding a print response before the data=json.loads(response) to see what you have received.


#3

I did what you instructed. Turns out a connection error was occurring repeatedly, due to which ‘response’ was returned as dictionary with values:

{‘message’ : ‘A Connection error occurred’ , ‘success’ : ‘0’}

Any idea how to deal with this?


#4

@naruto.amigo30 Connection error mostly occurs because the computer/VM in which you are running the program does not have access to the Internet.
In your case, check if your VM/Laptop/PC has access to the internet and try again.


#5

My VM had continuous access to the Internet during the operation. So, for solution, I did a ‘Jugaad’ by using Try-Except, and restarting bolt when ever the connection error occurred.:sweat_smile: