Python Forum
Occasional error when taking an item off a queue - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Occasional error when taking an item off a queue (/thread-15488.html)



Occasional error when taking an item off a queue - Wiggy - Jan-19-2019

I am using a queue to send commands to a GPS module. The commands are AT codes with 0,1 or 2 parameters. The command causing the problem is the +CCLK? command which asks for the time. It takes no parameters. The command is issued every few seconds and mainly it works fine, for hours, sometimes days. Once in a while, when I read the command from the queue, I get an 'Unpacking error' with the information that the wrong number of parameters was supplied.
The relevant code where the command is loaded is:

 CMD_Queue.put(("+CCLK?",None,None)) 
And is read by

 
try:
   Command, txtParam, numParam=CMD_Queue.get() 
except:
print("Unpacking error")

Any clues as to how to investigate this, or code a recovery from it please?


RE: Occasional error when taking an item off a queue - Gribouillis - Jan-19-2019

Wiggy Wrote:Any clues as to how to investigate this
instead of print('Unpacking error'), let the expression propagate to see what python says. Replace the print with the statement raise