urllib2.urlopen don't work with separate threads
<p>I'm working on an application to download the code of a web page and captures the links.
It works, but if I connect the program to a GUI, it locks the corresponding button until the download is completed.</p>

<p>If I trigger the download via a separate thread, to avoid the button lock, it just freezes and does not complete execution.</p>

<p>Is this normal? Or am I missing something?</p>

<p>Below goes the snippet of code. If I call grab() from a separate thread, nothing happens, neither errors. </p>

<p>The function update_observers() only notifies the observers, not doing else.
The observer is the responsible by making any changes, in this case, redraw the GUI.</p>

<pre><code>def grab(self, url):        
        try:
            self._status = 'Downloading page.'
            self.update_observers()
            inpu = urllib2.urlopen(url)

        except URLError, e:
            self._status = 'Error: '+ e.reason
            self.update_observers()
            return None

        resp = []  
        self._status = 'Parsing links'
        self.update_observers()
        for line in inpu.readlines():
            for reg in self._regexes:
                links = reg.findall(line)
                for link in links:
                    resp.append(link)

        self._status = 'Ready.'
        self.update_observers()
        return resp
</code></pre>

<p>This code is called here:</p>

<pre><code>def grab(self, widget):
    t = Thread(target=self.work)
    t.setDaemon(True)
    t.start()

def work(self):
    print "Working"
    self.links = None
    self.links = self.grabber.grab(self.txtLink.get_text())
    for link in self.links:
        self.store.append([link])
    print "Ok."
</code></pre>

<p>If I move the code from work() to grab, removing the threading stuff, it's all ok.</p>
