SocketServer shutdown deadlock

Discussion in 'Python' started by Okko Willeboordse, Nov 6, 2008.

  1. All,

    With Python 2.5 SocketServer features the shutdown method that can be
    called from another thread to stop the serve_forever loop.

    However;

    When the shutdown method is called before serve_forever, shutdown will
    never return.
    This can happen when a server is stopped during startup.

    In other words, the following program shouldn't hang but it does;

    import SocketServer

    server = SocketServer.ThreadingTCPServer(("127.0.0.1", 12345),
    SocketServer.BaseRequestHandler)
    server.shutdown()

    What to do?
    Okko Willeboordse, Nov 6, 2008
    #1
    1. Advertising

  2. If I wait until _BaseServer__serving is True before calling shutdown
    things go better.



    Okko Willeboordse wrote:
    > All,
    >
    > With Python 2.5 SocketServer features the shutdown method that can be
    > called from another thread to stop the serve_forever loop.
    >
    > However;
    >
    > When the shutdown method is called before serve_forever, shutdown will
    > never return.
    > This can happen when a server is stopped during startup.
    >
    > In other words, the following program shouldn't hang but it does;
    >
    > import SocketServer
    >
    > server = SocketServer.ThreadingTCPServer(("127.0.0.1", 12345),
    > SocketServer.BaseRequestHandler)
    > server.shutdown()
    >
    > What to do?
    Okko Willeboordse, Nov 6, 2008
    #2
    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,083
    Janusz
    Jun 1, 2004
  2. john
    Replies:
    4
    Views:
    567
    Lee Fesperman
    Jun 3, 2005
  3. lebo
    Replies:
    4
    Views:
    1,073
    Peter Hansen
    Jun 24, 2003
  4. Barry Sprajc
    Replies:
    1
    Views:
    384
    Skip Montanaro
    Aug 3, 2003
  5. Liam Slusser

    socketserver and postgres

    Liam Slusser, Oct 6, 2003, in forum: Python
    Replies:
    0
    Views:
    349
    Liam Slusser
    Oct 6, 2003
Loading...

Share This Page