New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
urllib hangs when closing connection #55408
Comments
If you run the attached program, you can see the program hangs in the connection close stage. Uncommenting the sleep line makes the program work, so I suspect some kind of race condition. The URL used belongs to a Slackware Linux mirror. I have not been able to reproduce this problem when using a different FTP mirror or using HTTP mirrors. The remote server seems to be using pure-ftpd. I have built the software and tested on localhost, but I could not reproduce the problem either. |
The problem is due to the way urllib closes a FTP data transfer. |
That makes sense and explains why the problem could not be reproduced over the loopback (the transfer would be too fast). I have not tested the patch, but I can reproduce the problem with a local connection if I compile pure-ftpd with the --with-throttling switch and limit the bandwidth to 1 KB/sec, using the -t option. |
I just tested the patch under Python 2.6. It doesn't seem to solve the problem. |
Are you sure the patch applied cleanly ? |
I have to correct myself. I applied the patch manually to my Python 2.6 installation. In Python 2.6, the line you moved is number 961, and I did the same change. With your change, the connection can be closed, but you have to wait for the file to be completely transferred. As I was throttling to 1 KB/sec initially, I thought it was still hanging because it takes more than 1 minute for the test file to be sent. Still, the connection isn't immediately closed when you request to close it. |
OK. For information, you can apply it using the Unix "patch" command,
That's expected, it's a consequence of this point I raised earlier:
The current code explicitely waits for the end of transfer before |
Yes, thanks, I already knew about "patch" but decided to apply the
There's no doubt that not hanging is an improvement, but the current To get a broader view, the test case I provided is actually part of a |
Attached are two new versions which don't wait for the end of transfer. |
Charles-Francois Natali, Tuesday, February 22, 2011 20:57:
I tested the one for Python 2.7 applied to Python 2.6 and it appears to |
New changeset 6ce4868861ba by Senthil Kumaran in branch '2.7': New changeset 891184abbf6e by Senthil Kumaran in branch '3.2': New changeset 9e7374779e19 by Senthil Kumaran in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: