Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Buffered streaming

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


ken at seehart

Nov 26, 2009, 10:02 AM

Post #1 of 3 (166 views)
Permalink
Buffered streaming

I need to create a pipe where I have one thread (or maybe a generator)
writing data to the tail while another python object is reading from the
head. This will run in real time, so the data must be deallocated after
it is consumed. Reading should block until data is written, and writing
should block when the buffer is full (i.e. until some of the data is
consumed). I assume there must be a trivial way to do this, but I don't
see it. Any ideas or examples?

I'm using python 2.6.


tjreedy at udel

Nov 26, 2009, 10:30 AM

Post #2 of 3 (149 views)
Permalink
Re: Buffered streaming [In reply to]

Ken Seehart wrote:
> I need to create a pipe where I have one thread (or maybe a generator)
> writing data to the tail while another python object is reading from the
> head. This will run in real time, so the data must be deallocated after
> it is consumed.

CPython does that when last reference disappears.

> Reading should block until data is written, and writing
> should block when the buffer is full (i.e. until some of the data is
> consumed). I assume there must be a trivial way to do this, but I don't
> see it. Any ideas or examples?
>
> I'm using python 2.6.
>
queue module

--
http://mail.python.org/mailman/listinfo/python-list


davea at ieee

Nov 26, 2009, 11:50 AM

Post #3 of 3 (156 views)
Permalink
Re: Buffered streaming [In reply to]

Ken Seehart wrote:
> I need to create a pipe where I have one thread (or maybe a generator)
> writing data to the tail while another python object is reading from
> the head. This will run in real time, so the data must be deallocated
> after it is consumed. Reading should block until data is written, and
> writing should block when the buffer is full (i.e. until some of the
> data is consumed). I assume there must be a trivial way to do this,
> but I don't see it. Any ideas or examples?
>
> I'm using python 2.6.
>
>
Seems to me collections.deque is a good data structure for the purpose,
at least if both operations are in the same thread.

For multithreading, consider Queue module (or queue in Python 3.x).

DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.