With another search on the web.. I have found the answer I was searching on yesterday: Queue with thread.
How? you can read here a good guide.
So anytime the code need to fetch data from the web, there is a good thread who can manage it.
I would like to see a urllib2 library completely asynchronous.. but for now.. you need threads.
Other things I did..a lot of bugfixing and a little bit of code cleaning.
I have also found another bug while displaying data on the chart.
Next step, will be chart improvements... and than..
first alpha will be out!
Showing posts with label pythread. Show all posts
Showing posts with label pythread. Show all posts
Saturday, 30 June 2012
Talking with Thread
Friday, 29 June 2012
Baby, did a bad, bad thing
Yesterday I wasted a little bit of time searching to find a bug: I had to delete a selected element from the list of registered stocks in the main screen, and also from the internal db.
Everytime I searched to delete one element from the list, the deletion of that element from internal db doesn't work... instead it was deleting another element.
The code was something like that:
So the code changed like this:
Now add and delete of stocks works.
The other problem is with pygtk and thread.. As I mentioned before.. everytime the application try to connect to the web the interface freeze until this operation is complete.
This happened because retrieving data from the net, it is a blocking operation, and block the main thread where the GTK engine runs.. so the application freeze.
I read so many pages about which is the best way to implements a Thread.. and I hope to be near to a solution.. but not yet!
Everytime I searched to delete one element from the list, the deletion of that element from internal db doesn't work... instead it was deleting another element.
The code was something like that:
- get the iterator and model , for the selected element of the treeview.
- remove the element from the model giving the iterator.
- the iterator became invalid...(yes it is deleted!) so I did the same thing of step 1.
- remove the element form the db getting the key from the iterator.
So the code changed like this:
- get the iterator and model , for the selected element of the treeview.
- remove the element form the db getting the key from the iterator.
- remove the element from the model giving the iterator.
Now add and delete of stocks works.
The other problem is with pygtk and thread.. As I mentioned before.. everytime the application try to connect to the web the interface freeze until this operation is complete.
This happened because retrieving data from the net, it is a blocking operation, and block the main thread where the GTK engine runs.. so the application freeze.
I read so many pages about which is the best way to implements a Thread.. and I hope to be near to a solution.. but not yet!
Labels:
liststore,
pygtk,
pythread,
ubuntuappshowdown
Subscribe to:
Posts (Atom)