Twisted - howto transport megabytes?
Moshe Zadka
m at moshez.org
Sun Jun 8 01:55:20 EDT 2003
Metaresponse: Twisted questions belong on the Twisted mailing list,
not here.
On Sun, 08 Jun 2003, "Ed Young" <ejy712 at comcast.net> wrote:
> When receiving large messages (multiple megabytes), I can
> use the dataReceived method to get the messages piecemeal.
> Since file writes can be blocking, how can I write the
> received pieces to a file in a non-blocking fashion?
In UNIX, file writes never block. Can you clarify what you're talking
about?
> When sending large messages (multiple megabytes), well,
> I haven't figured that out yet. Does the transport
> method accept a filehandle from which it will feed as
> it needs to?
You should "register a producer" on the transport.
See twisted.web.static.FileTransfer for how to register producers.
The 5-line explanation
transport.registerProducer(instance)
instance should support "resumeProducing()" which should call the
transport.write with a small amount of data (several Ks), and
"pauseProducing()" (which usually does nothing) and
"stopProducing()" which means the file isn't needed anymore.
--
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/
More information about the Python-list
mailing list