By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,690 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

Question Regarding SocketServer

P: n/a
Hi,
I am newbie to Python language and am taking my baby steps. I am
using Python2.4 from ActiveState on W2K. I am trying to create a simple
SocketServer program. Just adding the following 2 lines of code in the
program result in the errors given below:
import SocketServer
print "SocketServer imported"

Running the above cause the following errors

Traceback (most recent call last):
File "TestServer3.py", line 2, in ?
import SocketServer
File "C:\Python24\lib\SocketServer.py", line 8, in ?
- AF_INET{,6}: IP (Internet Protocol) sockets (default)
AttributeError: 'module' object has no attribute 'StreamRequestHandler'
I actually had more code to get the server running (actually it runs on
Linux), but it was throwing up errors on Windows, so I stripped it down
to the bare minimum to see where I am having an issue. I dont
understand why this is happening. Can someone point to me what I am
doing wrong or what is wrong with my configuration.

Thanks,
Kris

Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
you are missing quotes in "socketserver.py". Make sure the comments at
the top are quoted out. In "IDLE" they should be green.

Jul 18 '05 #2

P: n/a
I tried to reply earlier... basically your "SocketServer.py" file is
messed up. That line "AF_INET{,6}: IP (Internet Protocol) sockets
(default)" should be commented out. It should be part of a block of
lines that are all commented out.

Jul 18 '05 #3

P: n/a

sp*****@gmail.com wrote:
I tried to reply earlier... basically your "SocketServer.py" file is
messed up. That line "AF_INET{,6}: IP (Internet Protocol) sockets
(default)" should be commented out. It should be part of a block of
lines that are all commented out.


Thanks for your quick response. I am suprised that "SocketServer.py" is
messed up because I just installed Python and didnt touch any files in
Python's installation folder. Anyway I removed the comments at the top
and I still get the error

File "C:\Python24\lib\SocketServer.py", line 8, in ?

AttributeError: 'module' object has no attribute 'StreamRequestHandler'


If it is of any help here are the first few lines in SocketServer.py
__version__ = "0.4"
import socket
import sys
import os

__all__ =
["TCPServer","UDPServer","ForkingUDPServer","Forkin gTCPServer",

"ThreadingUDPServer","ThreadingTCPServer","BaseReq uestHandler",
"StreamRequestHandler","DatagramRequestHandler ",
"ThreadingMixIn", "ForkingMixIn"]
if hasattr(socket, "AF_UNIX"):
__all__.extend(["UnixStreamServer","UnixDatagramServer",
"ThreadingUnixStreamServer",
"ThreadingUnixDatagramServer"])
I opened the SocketServer.py in the IDE and it seems normal. Is there a
way I can check if the module is corrupted in the IDE?

Thanks,
Kris

Jul 18 '05 #4

P: n/a
I figured out my problem. I initially had named my program
SocketServer.py and then compiled it. It created a file
SocketServer.pyc
Then I changed the name of the program to TestServer3.py
but when I imported SocketServer, it was importing from the compiled
file left in the current folder (SocketServer.pyc) I guess. I deleted
it and everything worked. Please bear with my ignorance.
Thanks once again for the help,
Kris

Jul 18 '05 #5

P: n/a
I am glad you were able to figure it out. It's strange that the pyc
file didn't get updated... it should have automatically fixed itself.
*shrug* that's one of those problems that aggrivate you to death...

Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.