Skip to main content
GameDev.net gamedev.net
🔒 Locked

Threading question

Started by AdamShultz Sep 7, 2011 at 7:04 PM 6 replies 1.4k views
Original Post
AdamShultz
AdamShultz
Windows XP Pro v2002 SP3

Language: Python 2.7

Does anyone know if this OS honors daemon threads or not? I am getting quirky process behaviour when re-starting servers without explicitly ending the process. This does not happen on my windows 7 PC, at least not to the point where I could replicate it.
0x3a
0x3a
As far as I know it should not be a problem, what 'quirky process behavior' are you getting ?
If I've helped you in any way please push the reputation button, thanks!

Abstraction is my choice of words.
Portfolio: http://www.0x3a.com/
Blog: http://blog.0x3a.com/
AdamShultz
AdamShultz

As far as I know it should not be a problem, what 'quirky process behavior' are you getting ?


The process for my server module remains running when I close out of cmd and the module itself. I have to manually end the process in order to re-start the server and it's a PITA.

I'm setting thread.daemon to True when I instantiate a server. So basically every time I try to re-start the server and the process is still running (which it SHOULDNT BE, due to thread.daemon being == True), I get the 'only one usage of each socket address is permitted' error. So it's like a giant circle of WTF.

Any ideas?
0x3a
0x3a
Indeed a big circle of wtf, is this on a VM or a real computer ?

I don't really get whats going on, you reported that on Win7 it works just fine, is this 64bit or 32bit ? Also, the XP is 32bit or 64bit ?
If I've helped you in any way please push the reputation button, thanks!

Abstraction is my choice of words.
Portfolio: http://www.0x3a.com/
Blog: http://blog.0x3a.com/
ApochPiQ
ApochPiQ
I spent a few moments on Google and turned up a handful of bugs in various versions of Python which might be related. Make sure you're on the latest possible version of Python you can manage, and see if that helps; otherwise, you might try searching around for similar problems to see if anyone has a good workaround.
AdamShultz
AdamShultz

Indeed a big circle of wtf, is this on a VM or a real computer ?

I don't really get whats going on, you reported that on Win7 it works just fine, is this 64bit or 32bit ? Also, the XP is 32bit or 64bit ?


Real computer.

XP computer is 32 bit
Win7 computer is 64 bit

Sorry for not specifying that.


I spent a few moments on Google and turned up a handful of bugs in various versions of Python which might be related. Make sure you're on the latest possible version of Python you can manage, and see if that helps; otherwise, you might try searching around for similar problems to see if anyone has a good workaround.


I guess it makes sense to at least try that. Thanks for the info.
hplus0603
hplus0603

XP computer is 32 bit
Win7 computer is 64 bit


The tools you need are procmon and netstat.

If you do "netstat -na" when you can't start the new process, is there a socket in TIME_WAIT state?

If you look in procmon when you can't start the new process, is the process still running?

If the answer is "Yes" and "No," then the problem is that the TCP port is being timed out, waiting for potentially stray IP packets to come in. This means you can't re-bind to the port for a period of about 2 minutes or so.

The work-around is to set the SO_REUSEADDR socket option on the socket after you create it, but before you bind it to the port.
enum Bool { True, False, FileNotFound };
AdamShultz
AdamShultz

The tools you need are procmon and netstat.

The work-around is to set the SO_REUSEADDR socket option on the socket after you create it, but before you bind it to the port.


Thanks for this. I'll have to learn about netstat and procmon, as I have no experience using either (I only started learning how to write code 7 months ago), however this work-around seems quite simple.

Also, my apologies. I made a glaring error in one of my posts stating that I was using cmd when in fact I was using IDLE (I'm writing this in Python). IDLE is astoundingly slow and buggy with certain things, and a lot of these bugs cmd just doesn't have. It also doesn't throw as many exceptions as cmd does, which can get annoying... just a few observations of mine over the last few months.

The same thing still happens in cmd, though the time out is far less than when I run these in IDLE, sometimes to the point where I don't need to end the process because a small change in code that I needed to make before a re-test was, I guess, just enough time for the process to end itself.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.