Question Regarding SocketServer

M

missiplicity

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
 
S

sp1d3rx

you are missing quotes in "socketserver.py". Make sure the comments at
the top are quoted out. In "IDLE" they should be green.
 
S

sp1d3rx

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.
 
M

missiplicity

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","ForkingTCPServer",

"ThreadingUDPServer","ThreadingTCPServer","BaseRequestHandler",
"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
 
M

missiplicity

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
 
S

sp1d3rx

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top