Rev 3520: Don't require patched version for pyftpdlib. in file:///net/bigmamac/Volumes/home/vila/src/bzr/experimental/more-ftp/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Mar 2 19:54:37 GMT 2009
At file:///net/bigmamac/Volumes/home/vila/src/bzr/experimental/more-ftp/
------------------------------------------------------------
revno: 3520
revision-id: v.ladeuil+lp at free.fr-20090302195435-goqqmr9lhwr5z03u
parent: v.ladeuil+lp at free.fr-20090302142604-guy21k12jikewl37
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: pyftpdlib
timestamp: Mon 2009-03-02 20:54:35 +0100
message:
Don't require patched version for pyftpdlib.
* bzrlib/tests/ftp_server/pyftpdlib_based.py:
(FTPServer.setUp, tearDown, _run_server): Use lock to ensure we
wait for the server to start and use pyftpdlib without any
patches.
* bzrlib/tests/ftp_server/__init__.py:
Fix python version for medusa support.
-------------- next part --------------
=== modified file 'bzrlib/tests/ftp_server/__init__.py'
--- a/bzrlib/tests/ftp_server/__init__.py 2009-03-01 10:02:00 +0000
+++ b/bzrlib/tests/ftp_server/__init__.py 2009-03-02 19:54:35 +0000
@@ -25,7 +25,7 @@
try:
from bzrlib.tests.ftp_server import medusa_based
# medusa is bogus under python2.6
- medusa_available = sys.version_info <= (2, 5)
+ medusa_available = sys.version_info < (2, 6)
except ImportError:
medusa_available = False
=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
--- a/bzrlib/tests/ftp_server/pyftpdlib_based.py 2009-03-02 14:26:04 +0000
+++ b/bzrlib/tests/ftp_server/pyftpdlib_based.py 2009-03-02 19:54:35 +0000
@@ -183,22 +183,29 @@
self._port = self._ftp_server.socket.getsockname()[1]
# Don't let it loop forever, or handle an infinite number of requests.
# In this case it will run for 1000s, or 10000 requests
- self._async_thread = threading.Thread(
+ self._ftpd_starting = threading.Lock()
+ self._ftpd_starting.acquire() # So it can be released by the server
+ self._ftpd_thread = threading.Thread(
target=self._run_server,)
- self._async_thread.start()
+ self._ftpd_thread.start()
+ # Wait for the server thread to start (i.e release the lock)
+ self._ftpd_starting.acquire()
+ self._ftpd_starting.release()
def tearDown(self):
"""See bzrlib.transport.Server.tearDown."""
- # Tell the server to stop
- self._ftpd_running = False
- # But also close the server socket for tests that start the server but
- # never initiate a connection.
+ # Tell the server to stop, but also close the server socket for tests
+ # that start the server but never initiate a connection. Closing the
+ # socket should be done first though, to avoid further connections.
self._ftp_server.close()
- self._async_thread.join()
+ self._ftpd_running = False
+ self._ftpd_thread.join()
def _run_server(self):
"""Run the server until tearDown is called, shut it down properly then.
"""
self._ftpd_running = True
- self._ftp_server.serve_forever(timeout=0.1, count=10000,
- until=lambda : not self._ftpd_running)
+ self._ftpd_starting.release()
+ while self._ftpd_running:
+ self._ftp_server.serve_forever(timeout=0.1, count=1)
+ self._ftp_server.close_all(ignore_all=True)
More information about the bazaar-commits
mailing list