[Python-bugs-list] [ python-Bugs-471720 ] ThreadingMixIn/TCPServer forgets close

noreply@sourceforge.net noreply@sourceforge.net
Wed, 17 Oct 2001 02:10:49 -0700


Bugs item #471720, was opened at 2001-10-16 07:04
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=471720&group_id=5470

Category: Documentation
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Max Neunhöffer (neunhoef)
Assigned to: Guido van Rossum (gvanrossum)
Summary: ThreadingMixIn/TCPServer forgets close

Initial Comment:
When using the SocketServer.TCPServer class in connection with the SocketServer.ThreadingMixIn class
every request produces an open socket, because
the overloaded process_request method only calls
the finish_request method without calling close_request afterwards.

The test in test_socketserver.py does not notice
this.

This is true for Python 2.1.1 and Python 2.2a4.

Documentation for ThreadingMixIn (and ForkingMixIn)
is a little meager.


----------------------------------------------------------------------

>Comment By: Max Neunhöffer (neunhoef)
Date: 2001-10-17 02:10

Message:
Logged In: YES 
user_id=350896

This is a context diff of a proposal for a patch


relative to the current state of CVS.


I have to admit that I tested this only with 2.2a4


and not with the current CVS version.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-16 17:26

Message:
Logged In: YES 
user_id=6380

OK. It would be a great help if you could upload a patch (a
context diff) relative to the current state of CVS, or the
2.2a4 release if you must. When uploading, don't forget to
check the file upload checkbox.

----------------------------------------------------------------------

Comment By: Max Neunhöffer (neunhoef)
Date: 2001-10-16 15:01

Message:
Logged In: YES 
user_id=350896

I suggest changing only the ThreadingMixIn class in the
following way:

(1) Add a method process_request_thread which does exactly
the same as
    the process_request method of the BaseServer class:
      call finish_request
      call close_request

(2) The overloaded process_request method does not launch
the finish_request
    method as a new thread but instead the
process_request_thread method. 

Another possibility would be to somehow access the
process_request method
of the corresponding base class generically. However I do
not know a way
to access this easily and cleanly.

Still the documentation to ThreadingMixIn and ForkingMixIn
could be improved.

I do not know the sourceforge bug tracker well enough to
merge these "threads"
as montenaro suggests.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2001-10-16 09:12

Message:
Logged In: YES 
user_id=44345

I am getting a sense of deja vu.

Before we march down this path, can we revisit (and perhaps collapse this into) the previous "thread" on this subject:

http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=417845

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-16 08:35

Message:
Logged In: YES 
user_id=6380

Can you suggest a fix then?

----------------------------------------------------------------------

Comment By: Max Neunhöffer (neunhoef)
Date: 2001-10-16 07:49

Message:
Logged In: YES 
user_id=350896

I would not like this, because then the correct code for
a handler of a ThreadingMixIn/TCPServer would be different from a standard TCPServer.
It is also not very intuitive from a programmers point of view, who only wants to use the server library.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-16 07:31

Message:
Logged In: YES 
user_id=6380

Let's make this a documentation issue. When using threading,
the thread is responsible for closing the socket.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=471720&group_id=5470