Closed bplimley closed 7 years ago
Hi, Brian I'm not sure what the problem is for this specific issue. If a cpm fails to send, it will go to queue (send_to_memory method). If main undergoes a regular_send (network is up) then the queue is left-popped to a temporary trash variable which is used to send the cpm popped from the queue.
Sorry for the delayed response. Let me just describe it more specifically with an example.
DataHandler.main()
is called with cpm=2
.
DataHandler.regular_send()
happens with cpm=2
.sender.send_cpm_new()
happens with cpm=2
.DataHandler.regular_send()
starts flushing the queue with the while
loop.sender.send_cpm_new()
fails with a network error on a measurement with cpm=0
.DataHandler.main()
. That's good but self.send_to_memory(cpm, cpm_err)
is sending cpm=2
to memory, not cpm=0
!Maybe you want to use DataHandler.main()
in the while
loop. I haven't thought it through though.
There's also another bug here, let me make a new issue for it.
I made some changes. When it tries to send entries in the queue now, it undergoes a try and except for each entry in the queue. If it fails, the entry is placed back in the queue and datahandler stops iterating through the queue. I also added some arguments to some of the methods in datahandler in order to implement this.
@tybtab FYI, I tested this on my device and it looks like it works fine.
While a backlog of data is being flushed to the server in
DataHandler.regular_send()
, there is potential for a network error (especially if the server is receiving heavy traffic). Currently this network error is caught inDataHandler.main()
but not handled correctly (cpm
is saved to queue, rather thantrash[0]
etc.)