Rev 2417: (John Arbash Meinel) When shutting down the test FtpServer, trap EBADF in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Apr 13 17:02:41 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2417
revision-id: pqm at pqm.ubuntu.com-20070413160237-0weampli2rrmzjht
parent: pqm at pqm.ubuntu.com-20070413153758-6rwva0hs3h07wmpl
parent: john at arbash-meinel.com-20070413142902-28o8mnhj2sk5qcpg
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-04-13 17:02:37 +0100
message:
(John Arbash Meinel) When shutting down the test FtpServer, trap EBADF
modified:
bzrlib/transport/ftp.py ftp.py-20051116161804-58dc9506548c2a53
------------------------------------------------------------
revno: 2413.3.2
merged: john at arbash-meinel.com-20070413142902-28o8mnhj2sk5qcpg
parent: john at arbash-meinel.com-20070412213837-cim2mupcek5kjyw3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: ftp_ignore_ebadf
timestamp: Fri 2007-04-13 09:29:02 -0500
message:
cleanup comment (from Martin)
------------------------------------------------------------
revno: 2413.3.1
merged: john at arbash-meinel.com-20070412213837-cim2mupcek5kjyw3
parent: pqm at pqm.ubuntu.com-20070412150356-jeie6iap22sae8xf
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: ftp_ignore_ebadf
timestamp: Thu 2007-04-12 16:38:37 -0500
message:
Trap EBADF during shutdown of asyncore.loop()
=== modified file 'bzrlib/transport/ftp.py'
--- a/bzrlib/transport/ftp.py 2007-04-12 20:56:34 +0000
+++ b/bzrlib/transport/ftp.py 2007-04-13 16:02:37 +0000
@@ -31,6 +31,7 @@
import os
import urllib
import urlparse
+import select
import stat
import threading
import time
@@ -569,7 +570,8 @@
self._port = self._ftp_server.getsockname()[1]
# Don't let it loop forever, or handle an infinite number of requests.
# In this case it will run for 100s, or 1000 requests
- self._async_thread = threading.Thread(target=asyncore.loop,
+ self._async_thread = threading.Thread(
+ target=FtpServer._asyncore_loop_ignore_EBADF,
kwargs={'timeout':0.1, 'count':1000})
self._async_thread.setDaemon(True)
self._async_thread.start()
@@ -581,6 +583,19 @@
asyncore.close_all()
self._async_thread.join()
+ @staticmethod
+ def _asyncore_loop_ignore_EBADF(*args, **kwargs):
+ """Ignore EBADF during server shutdown.
+
+ We close the socket to get the server to shutdown, but this causes
+ select.select() to raise EBADF.
+ """
+ try:
+ asyncore.loop(*args, **kwargs)
+ except select.error, e:
+ if e.args[0] != errno.EBADF:
+ raise
+
_ftp_channel = None
_ftp_server = None
More information about the bazaar-commits
mailing list