urllib.urlopen blocking?

Dominik Gabi dkgispam at gmail.com
Tue May 11 09:22:29 EDT 2010


Hi,

I'm new to python and have been playing around with it for a few days
now. So please forgive me if this is a stupid question :)

I've tried writing a little application with pygtk and urllib. When a
button is clicked I create a new thread that opens an URL with urllib.
The new thread is running but as soon as I call
urllib.urlopen("https://someurl", postdata) it blocks. It blocks until
I do something in the interface (e.g. click another button). I've
obviously missed something here. The interface should not interfere
with anything that runs in an other thread!?

Here are a few extracts from my code:

def send_message(self, widget, data=None):
  # This is called when the button is clicked ...
  threading.Thread(target=message.send).start() ...

def send(self):
  # This is executed in its own thread
  ...
  postdata = urllib.urlencode(data) # This line is the last one
executed
  resp = urllib.urlopen('https://theurl', postdata)

Regards, Dominik.



More information about the Python-list mailing list