<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Download Files Async With Gio And Python</title>
	<atom:link href="http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/</link>
	<description>At home with Jono Bacon, Community Manager and Author</description>
	<lastBuildDate>Sat, 11 Feb 2012 21:46:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: hb</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137768</link>
		<dc:creator>hb</dc:creator>
		<pubDate>Sun, 21 Mar 2010 09:09:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137768</guid>
		<description>&lt;p&gt;Is there a way to monitor % of download ?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Is there a way to monitor % of download ?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Shaw</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137051</link>
		<dc:creator>Joe Shaw</dc:creator>
		<pubDate>Tue, 16 Mar 2010 01:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137051</guid>
		<description>&lt;p&gt;One final comment: if you are using load_contents(), you are storing the entire contents of the file in memory.  This is not a big deal if you are downloading a 1 or even a 100 kilobyte file, but if you&#039;re talking about several megabytes, that is a considerable waste.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>One final comment: if you are using load_contents(), you are storing the entire contents of the file in memory.  This is not a big deal if you are downloading a 1 or even a 100 kilobyte file, but if you&#8217;re talking about several megabytes, that is a considerable waste.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Shaw</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137050</link>
		<dc:creator>Joe Shaw</dc:creator>
		<pubDate>Tue, 16 Mar 2010 00:49:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137050</guid>
		<description>&lt;p&gt;Oh well, that code formatting got butchered...&lt;/p&gt;

&lt;p&gt;http://gist.github.com/333511&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Oh well, that code formatting got butchered&#8230;</p>

<p><a href="http://gist.github.com/333511" rel="nofollow">http://gist.github.com/333511</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Shaw</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137049</link>
		<dc:creator>Joe Shaw</dc:creator>
		<pubDate>Tue, 16 Mar 2010 00:47:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137049</guid>
		<description>&lt;p&gt;GIO has always felt a little awkward to me, and it seems especially so when translated into Python.&lt;/p&gt;

&lt;p&gt;I&#039;m rather fond of the Node.js way, but maybe it&#039;s because I love Javascript&#039;s nestable function literals:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
var fs = require(&quot;fs&quot;);
var http = require(&quot;http&quot;);&lt;/p&gt;

&lt;p&gt;var client = http.createClient(80, &quot;google.com&quot;);
var request = client.request(&quot;GET&quot;, &quot;/&quot;, {&quot;host&quot;: &quot;google.com&quot;});
var file = fs.createWriteStream(&quot;google.html&quot;,
                                { flags: &quot;w&quot;,
                                  mode: 0644 });&lt;/p&gt;

&lt;p&gt;request.addListener(&quot;response&quot;, function(response) {
    response.addListener(&quot;data&quot;, function(chunk) {
        file.write(chunk);
    });
    response.addListener(&quot;end&quot;, function() {
        file.close();
    });
});
request.close();
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The beauty part about this is that it&#039;s entirely async -- both reads via HTTP and writes to the file system.  (Although this one ignores any errors, never mind about that. :)&lt;/p&gt;

&lt;p&gt;And, well, Node doesn&#039;t integrate with GTK.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>GIO has always felt a little awkward to me, and it seems especially so when translated into Python.</p>

<p>I&#8217;m rather fond of the Node.js way, but maybe it&#8217;s because I love Javascript&#8217;s nestable function literals:</p>

<p><code>
var fs = require("fs");
var http = require("http");</code></p>

<p>var client = http.createClient(80, "google.com");
var request = client.request("GET", "/", {"host": "google.com"});
var file = fs.createWriteStream("google.html",
                                { flags: "w",
                                  mode: 0644 });</p>

<p>request.addListener("response", function(response) {
    response.addListener("data", function(chunk) {
        file.write(chunk);
    });
    response.addListener("end", function() {
        file.close();
    });
});
request.close();
</p>

<p>The beauty part about this is that it&#8217;s entirely async &#8212; both reads via HTTP and writes to the file system.  (Although this one ignores any errors, never mind about that. <img src='http://www.jonobacon.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>And, well, Node doesn&#8217;t integrate with GTK.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Derek</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137045</link>
		<dc:creator>Derek</dc:creator>
		<pubDate>Tue, 16 Mar 2010 00:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137045</guid>
		<description>&lt;p&gt;I like the example: very straightforward. I agree that asynchronously writing it to disk might be nice, but that could go in a different snippet.&lt;/p&gt;

&lt;p&gt;One thing that I wonder is how many characters you have per line? Is it 80? The code is a little truncated on your website (though it&#039;d be fine in Acire, of course).&lt;/p&gt;

&lt;p&gt;Glad you figured it out. :o)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I like the example: very straightforward. I agree that asynchronously writing it to disk might be nice, but that could go in a different snippet.</p>

<p>One thing that I wonder is how many characters you have per line? Is it 80? The code is a little truncated on your website (though it&#8217;d be fine in Acire, of course).</p>

<p>Glad you figured it out. <img src='http://www.jonobacon.org/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> )</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rodney Dawes</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137026</link>
		<dc:creator>Rodney Dawes</dc:creator>
		<pubDate>Mon, 15 Mar 2010 20:42:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137026</guid>
		<description>&lt;p&gt;GIO is nice, but it&#039;s not always what you want to use, as it&#039;s not designed to be an HTTP library, but a filesystem abstraction. In this sense, it&#039;s usually ok to use it to copy from one location to another.&lt;/p&gt;

&lt;p&gt;However, if to download a file, you need to do more complicated things with HTTP headers and auth, you will probably want to use libsoup (or httplib(2?) with GIOChannels).&lt;/p&gt;

&lt;p&gt;Also, I know people are oft afraid to use threads, because they&#039;re &quot;difficult&quot; to get right and all, but using threads in Python is pretty trivial (even with glib/gtk+), and will make it easier to do the write to disk async as well.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>GIO is nice, but it&#8217;s not always what you want to use, as it&#8217;s not designed to be an HTTP library, but a filesystem abstraction. In this sense, it&#8217;s usually ok to use it to copy from one location to another.</p>

<p>However, if to download a file, you need to do more complicated things with HTTP headers and auth, you will probably want to use libsoup (or httplib(2?) with GIOChannels).</p>

<p>Also, I know people are oft afraid to use threads, because they&#8217;re &#8220;difficult&#8221; to get right and all, but using threads in Python is pretty trivial (even with glib/gtk+), and will make it easier to do the write to disk async as well.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: jono</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137023</link>
		<dc:creator>jono</dc:creator>
		<pubDate>Mon, 15 Mar 2010 20:00:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137023</guid>
		<description>&lt;p&gt;Well, yeah...but I figured the write is pretty quick. I still need to port that to be async. :-)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Well, yeah&#8230;but I figured the write is pretty quick. I still need to port that to be async. <img src='http://www.jonobacon.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse van den Kieboom</title>
		<link>http://www.jonobacon.org/2010/03/15/download-files-async-with-gio-and-python/comment-page-1/#comment-137021</link>
		<dc:creator>Jesse van den Kieboom</dc:creator>
		<pubDate>Mon, 15 Mar 2010 19:52:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.jonobacon.org/?p=2527#comment-137021</guid>
		<description>&lt;p&gt;Of course you do realize that right now your writing to disk is done sync, and not async :) You could try the &#039;splice&#039; API to write an input stream to an output stream.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Of course you do realize that right now your writing to disk is done sync, and not async <img src='http://www.jonobacon.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You could try the &#8216;splice&#8217; API to write an input stream to an output stream.</p>]]></content:encoded>
	</item>
</channel>
</rss>

