I have a simple thread that grabs bytes from a Bluetooth RFCOMM (serial-port-like) socket and dumps them into a Queue.Queue
(FIFO), which seems like the typical method to exchange data between threads. Works fine.
Is this overkill though? Could I just use a bytearray then have my reader thread .append(somebyte)
and the processing function just .pop(0)
? I'm not sure if the protections in Queue are meant for more complex "multi-producer, multi-consumer queues" and a waste for a point-to-point byte stream. Doing things like flushing the queue or grabbing multiple bytes seem more awkward with the Queue vs. a simpler data type.
I guess the answer might have to do with if .pop()
is atomic, but would it even matter then?...