Question Regarding SocketServer

Discussion in 'Python' started by missiplicity@yahoo.com, Jan 25, 2005.

  1. Guest

    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
    , Jan 25, 2005
    #1
    1. Advertising

  2. Guest

    you are missing quotes in "socketserver.py". Make sure the comments at
    the top are quoted out. In "IDLE" they should be green.
    , Jan 25, 2005
    #2
    1. Advertising

  3. Guest

    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.
    , Jan 25, 2005
    #3
  4. Guest

    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","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
    , Jan 25, 2005
    #4
  5. Guest

    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
    , Jan 25, 2005
    #5
  6. Guest

    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...
    , Jan 26, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Janusz
    Replies:
    4
    Views:
    1,082
    Janusz
    Jun 1, 2004
  2. john
    Replies:
    4
    Views:
    565
    Lee Fesperman
    Jun 3, 2005
  3. lebo
    Replies:
    4
    Views:
    1,071
    Peter Hansen
    Jun 24, 2003
  4. Replies:
    2
    Views:
    307
  5. K Richard Pixley

    socketserver question

    K Richard Pixley, Jan 5, 2012, in forum: Python
    Replies:
    1
    Views:
    148
    Bryan
    Jan 8, 2012
Loading...

Share This Page