Patches item #1763387, was opened at 2007-07-30 06:38
Message generated for change (Comment added) made by jyasskin
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1763387&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Closed
Resolution: Rejected
Priority: 5
Private: No
Submitted By: Hasan Diwan (hdiwan650)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket close fixed

Initial Comment:
Patch fixes the race condition causing tests to mysteriously fail.

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

Comment By: Jeffrey Yasskin (jyasskin)
Date: 2007-08-05 01:04

Message:
Logged In: YES 
user_id=581856
Originator: NO

On OSX, I've seen both:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/Users/jyasskin/src/python/test_asyncore/Lib/threading.py", line
464, in __bootstrap
    self.run()
  File "/Users/jyasskin/src/python/test_asyncore/Lib/threading.py", line
444, in run
    self.__target(*self.__args, **self.__kwargs)
  File "Lib/test/test_asyncore.py", line 59, in capture_server
    serv.bind(("", PORT))
  File "<string>", line 1, in bind
socket.error: (48, 'Address already in use')

after which the interpreter freezes, and

======================================================================
ERROR: test_send (__main__.DispatcherWithSendTests_UsePoll)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_asyncore.py", line 351, in test_send
    d.send(data)
  File "/Users/jyasskin/src/python/test_asyncore/Lib/asyncore.py", line
467, in send
    self.initiate_send()
  File "/Users/jyasskin/src/python/test_asyncore/Lib/asyncore.py", line
454, in initiate_send
    num_sent = dispatcher.send(self, self.out_buffer[:512])
  File "/Users/jyasskin/src/python/test_asyncore/Lib/asyncore.py", line
334, in send
    if why[0] == EWOULDBLOCK:
TypeError: 'error' object is unindexable


I plan to fix the first by binding to port 0 as kuran suggested and using
.getsockname()[1] to retrieve the port number, and the second by figuring
out the right way to get the errno out of a socket.error.

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

Comment By: Facundo Batista (facundobatista)
Date: 2007-07-30 13:28

Message:
Logged In: YES 
user_id=752496
Originator: NO

This patch

  a) does not address the problem that appeared in the tests (it should be
solved in a very different way)
  b) as kuran correctly says, is conceptually wrong (see his comment)

Regards,

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

Comment By: Jp Calderone (kuran)
Date: 2007-07-30 10:06

Message:
Logged In: YES 
user_id=366566
Originator: NO

SO_REUSEADDR is a flag.  It's not a period of time measured in seconds. 
So using it with time.sleep() is conceptually broken, even though it
happens to do something without raising an exception.

And socket.close() really, really, really should not sleep for any length
of time at all.  It does what it needs to do by making the low-level call,
and then it can return.  If the port shouldn't be re-used for some period
of time, that is up to the application using the socket to deal with.

Since this ticket doesn't actually explain what the test failures _are_, I
can't really suggest an alternate solution.  I assume it is something to do
with binding to ports failing, though.  In this case, the tests should just
be changed to bind port 0, which will force the platform to select an
unused port.


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1763387&group_id=5470
_______________________________________________
Patches mailing list
Patches@python.org
http://mail.python.org/mailman/listinfo/patches

Reply via email to