A class Collector, it spawns several threads to read from serial port.
Collector.get_data() will get all the data they have read since last
call. Who can tell me whether my implementation correct?
class Collector(object):
def __init__(self):
self.data = []
Qiangning Hong wrote:
A class Collector, it spawns several threads to read from serial port.
Collector.get_data() will get all the data they have read since last
call. Who can tell me whether my implementation correct?
class Collector(object):
def __init__(self):
self.data = []
Qiangning Hong wrote:
A class Collector, it spawns several threads to read from serial port.
Collector.get_data() will get all the data they have read since last
call. Who can tell me whether my implementation correct?
[snip sample with a list]
I am not very sure about the get_data() method.
Peter Hansen wrote:
Qiangning Hong wrote:
A class Collector, it spawns several threads to read from serial port.
Collector.get_data() will get all the data they have read since last
call. Who can tell me whether my implementation correct?
[snip sample with a list]
I am not very sure
Previously, on Jun 14, Jeremy Jones said:
# Kent Johnson wrote:
#
# Peter Hansen wrote:
#
# Qiangning Hong wrote:
#
#
#A class Collector, it spawns several threads to read from serial port.
#Collector.get_data() will get all the data they have read since last
#call.
James Tanis wrote:
I may be wrong here, but shouldn't you just use a stack, or in other
words, use the list as a stack and just pop the data off the top. I
believe there is a method pop() already supplied for you.
Just a note on terminology here. I believe the word stack generally
refers
Kent Johnson wrote:
Peter Hansen wrote:
That will not work, and you will get data loss, as Jeremy points out.
Can you explain why not? self.data is still bound to the same list as x.
At least if the execution sequence is x = self.data
self.data.append(a_piece_of_data)
James Tanis wrote:
#A class Collector, it spawns several threads to read from serial port.
#Collector.get_data() will get all the data they have read since last
#call. Who can tell me whether my implementation correct?
#
# Here's the original code:
#
# class
Peter Hansen wrote:
James Tanis wrote:
I may be wrong here, but shouldn't you just use a stack, or in other
words, use the list as a stack and just pop the data off the top. I
believe there is a method pop() already supplied for you.
Just a note on terminology here. I believe the word
On Tuesday 14 June 2005 17:47, Peter Hansen wrote:
Kent Johnson wrote:
Peter Hansen wrote:
That will not work, and you will get data loss, as Jeremy points out.
Can you explain why not? self.data is still bound to the same list as x.
At least if the execution sequence is x = self.data
Qiangning Hong wrote:
I actually had considered Queue and pop() before I wrote the above code.
However, because there is a lot of data to get every time I call
get_data(), I want a more CPU friendly way to avoid the while-loop and
empty checking, and then the above code comes out. But I am
Previously, on Jun 14, Peter Hansen said:
# James Tanis wrote:
# I may be wrong here, but shouldn't you just use a stack, or in other
# words, use the list as a stack and just pop the data off the top. I
# believe there is a method pop() already supplied for you.
#
# Just a note on
Toby Dickenson wrote:
But it might not show up until too late.
The consumer thread that called get_data presumably does something with that
list, such as iterating over its contents. It might only show up after that
iteration has finished, when the consumer has discarded its reference to
13 matches
Mail list logo