Restarting Demon threads in Python

Having just spent over an hour trying to find how to do this, here is my contribution to the problem.

Say that you have a thread that you have called start() on, and your run() method terminates with an exception, or quite naturally (for example, your listening to a socket, and it gets disconnected).

Your problem becomes that you now need to be able to re-call that thread to get it started again. However, progmatically, there’s no way of knowing if you have already called .start() on that thread. The thread is no-longer alive, so that doesn’t work. You get this (or similar) error:

raise RuntimeError(“threads can only be started once”)

The answer (at least so far) seems to be that you need to re-initialise the thread. By Placing:

threading.Thread.__init__(self)

At the end of your run() method, you can then call .start() on that thread again to your hearts content.

Now, I have no idea if this is good programming, or if there is a better way of getting this done, but it works for me, and my needs.

~BX

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Installing Fedora 11 vs. Installing Windows 7 RC.

I decided, in some fit of madness to upgrade to Fedora 11, and to upgrade to Windows 7 RC on my dual-boot laptop. I thought that I would take advantage of the unaccustomed Generosity of Microsoft with their free version (that is, it’s free untill July next year).

First, let’s start with the upgrade.

Upgrade:

Fedora 11: Surprisingly painless. A small window popped up telling me that the download was available, and all I had to do was to click “Install”. This kicked of the downloading of all the relevant packages. Upon reboot, the computer asked the usuall questions about keyboard and, and then set about upgrading the computer. Job done.

Windows 7 RC: This is to be done from inside vista itself, and much to my surprise relatively painless. It required the extra step of creation of a DVD, but one that was done, it asked the same questions about the keyboard, and upgraded my Vista to Windows 7. This is a VAST improvement of previous upgrades of windows Software. It did also seem to fetch updates from Microsoft, the problem was that as this was done during the process of upgrading, it meant that the process left your computer unusable much longer than Fedora 11.

Experience

Fedora 11: As nothing much has changed on the interface, there was nothing new to report. The improvements meant that a lot more stuff had reached that stage of “Just Worked”. It appears to have solved an intermittent problem with my Wireless Network card, where it would just stop working, so that’s an improvement. Also, the random crashes when using Compiz Fusion seems to have gone as well. As with everything, a new upgrade made me revisit a few old favourites, and discovered that Evolution now allows me to sync with my Google Calendar, I don’t know how long it’s been able to do this, but it’s funky. I can also (using alltray) hide Evolution in my task-bar. Seems to work fine, but we’ll see how it works with more time.

Windows 7 RC.: A big change to the interface has made it somewhat confusing to use. I’m also not sure what the changes are designed to achieve. Having spent a lot of time trying to shift all the things that I have open to the system-tray, it was a surprise to discover that MSN now seems to want to take a place on the task-bar, rather than hiding it’s self away in the system-tray. As ever, IE is back on the Windows 7 version of the quick-launch, but it was a matter of seconds to remove it. Much to my surprise and delight, it appears that Firefox has remained my default web-browser. I guess the court ruling actually did make a few changes. The System Tray is now hidden away in a pop-up box, which for most things is fairly handy, and it’s fairly straight-forward to return things that you want to the sys-tray if you want them (like I use Adolix wall-paper changer to change my wall-paper every minit). By and large, the interface seems to be Vista with a few updates, most of which seem to have been done for “the look of the thing”, rather than for any kind of increase in functionality that I can see. An example is that default setting for the task-bar. In this, you can maximise windows, but not minimise them. We are used to being able to click on the button to raise a window, or to lower a window. This doesn’t seem to be the case in the Windows 7. Another odd thing that has just happened, is I randomly got a large Advert for Garnier appear in the foreground on the right-hand side. This vanished after a few seconds, and seems to be comming from Windows Live Messenger (MSN). That’s a massive invasion of my desktop. I don’t know what triggered it, or where it comes from.. we shall have to wait and see if it comes up again. Another odd thing seems to be that when I minimize firefox, the main windows of Windows Live appears. This could be a bug, so we have to remember that Windows 7 is still in development.

Conclusion

As “Pretty” as Windows 7 is, I think it’s too Much too late. The interface is excessive, and doesn’t seem to add anything to functionality. With the improvements in Fedora 11, the least user-friendly/tech heavy of the linux distro’s, I’m not sure that there’s any way that Microsoft can catch up. Considering that the programs I use for daily use are Firefox, Thunderbirt/Evolution, Open Office, and LaTex, there’s very little that is the pervue of Windows only. With Microsoft’s obsession with only allowing you to connect to Microsoft’s services, which by and large cost money there seems to be very little to come back to windows for. The only game that I play that is Windows-Only is World of Warcraft, and in the current climate that subscription has been cancelled. Of course, the ordinary person will be stuck using Microsoft while Business continue to insist on bying into the Microsoft Madness under the mistaken belief that it will save them on Tech Support Costs. People’s computer training comes mostly through their business and schools so until that changes, I guess Microsoft will hold tight on the world, despite it’s usefullness having been extinquished by their inability to inovate, or find another stream of monetizing to open up their operating system to interoportunity.

~Black Xanthus

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Getting LaTex word count which ignores footnotes

I’ve been wrighting my essays in LaTex every since I discovered that it made footnoting and other various items easier. The one thing it made harder, however, was doing the word-count.

Wanting to know how far through my 5000 word essay I was, I started trying to work out how. Lots of people say things like “Turn it into a pdf and copy it into word”. I’m sorry, but I don’t have that kind of time.

I spent some time searching, and eventually came accross a perl script:

http://www.comp.nus.edu.sg/~kanmy/software/texWordCount.pl

That I found here:

http://www.comp.nus.edu.sg/~kanmy/software.html

This was wonderful. Hats off to the guys that wrote it and updated it. However, I needed it to ignore the words in footnotes. They don’t count towards the word count for my theological essays, so I hacked it until it seemed to work. It works even if you include \textit{} to itallicise the book name, which I have to do in my footnotes. If you need it to do more, you will have to hack it yourself.

http://blog.valhalla.jara23.co.uk/?page_id=275

Also, this was a quick hack. It may not work in all cases. If you find it doesn’t, feel free to leave a comment, and I might fix it. Also, the word count has not been verified.

~Black Xanthus

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]