py3 object-server follow-ups
Change-Id: Ief7d85af8d3e1d5e03a6484a889c9146d69f1377 Related-Change: I203a54fddddbd4352be0e6ea476a628e3f747dc1
This commit is contained in:
parent
5b5ed29ab4
commit
2bd7b7a109
@ -95,24 +95,17 @@ def _make_backend_fragments_header(fragments):
|
||||
return None
|
||||
|
||||
|
||||
if six.PY2:
|
||||
class EventletPlungerString(str):
|
||||
"""
|
||||
Eventlet won't send headers until it's accumulated at least
|
||||
eventlet.wsgi.MINIMUM_CHUNK_SIZE bytes or the app iter is exhausted.
|
||||
If we want to send the response body behind Eventlet's back, perhaps
|
||||
with some zero-copy wizardry, then we have to unclog the plumbing in
|
||||
eventlet.wsgi to force the headers out, so we use an
|
||||
EventletPlungerString to empty out all of Eventlet's buffers.
|
||||
"""
|
||||
def __len__(self):
|
||||
return wsgi.MINIMUM_CHUNK_SIZE + 1
|
||||
else:
|
||||
# Eventlet of 0.23.0 does encode('ascii') and strips our __len__.
|
||||
# Avoid it by inheriting from bytes.
|
||||
class EventletPlungerString(bytes):
|
||||
def __len__(self):
|
||||
return wsgi.MINIMUM_CHUNK_SIZE + 1
|
||||
class EventletPlungerString(bytes):
|
||||
"""
|
||||
Eventlet won't send headers until it's accumulated at least
|
||||
eventlet.wsgi.MINIMUM_CHUNK_SIZE bytes or the app iter is exhausted.
|
||||
If we want to send the response body behind Eventlet's back, perhaps
|
||||
with some zero-copy wizardry, then we have to unclog the plumbing in
|
||||
eventlet.wsgi to force the headers out, so we use an
|
||||
EventletPlungerString to empty out all of Eventlet's buffers.
|
||||
"""
|
||||
def __len__(self):
|
||||
return wsgi.MINIMUM_CHUNK_SIZE + 1
|
||||
|
||||
|
||||
class ObjectController(BaseStorageServer):
|
||||
|
@ -48,7 +48,6 @@ from swift.obj import server
|
||||
from hashlib import md5
|
||||
import logging.handlers
|
||||
|
||||
import six
|
||||
from six.moves import range
|
||||
from six import BytesIO
|
||||
from six.moves.http_client import HTTPException
|
||||
@ -924,7 +923,7 @@ def fake_http_connect(*code_iter, **kwargs):
|
||||
def getheaders(self):
|
||||
etag = self.etag
|
||||
if not etag:
|
||||
if isinstance(self.body, six.binary_type):
|
||||
if isinstance(self.body, bytes):
|
||||
etag = '"' + md5(self.body).hexdigest() + '"'
|
||||
else:
|
||||
etag = '"68b329da9893e34099c7d8ad5cb9c940"'
|
||||
|
@ -6863,7 +6863,10 @@ class TestObjectController(unittest.TestCase):
|
||||
})
|
||||
resp = req.get_response(self.object_controller)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
suffix = list(pickle.loads(resp.body).keys())[0]
|
||||
suffixes = list(pickle.loads(resp.body).keys())
|
||||
self.assertEqual(1, len(suffixes),
|
||||
'Expected just one suffix; got %r' % (suffixes,))
|
||||
suffix = suffixes[0]
|
||||
self.assertEqual(suffix, os.path.basename(
|
||||
os.path.dirname(objfile._datadir)))
|
||||
# tombstone still exists
|
||||
@ -7619,7 +7622,7 @@ class TestObjectServer(unittest.TestCase):
|
||||
if six.PY2:
|
||||
conn.sock.fd._sock.close()
|
||||
else:
|
||||
conn.sock.fd.close()
|
||||
conn.sock.fd._real_close()
|
||||
for i in range(2):
|
||||
sleep(0)
|
||||
self.assertFalse(self.logger.get_lines_for_level('error'))
|
||||
@ -7722,7 +7725,7 @@ class TestObjectServer(unittest.TestCase):
|
||||
|
||||
# give the object server a little time to trampoline enough to
|
||||
# recognize request has finished, or socket has closed or whatever
|
||||
sleep(0.1)
|
||||
sleep(0.01)
|
||||
|
||||
def test_multiphase_put_client_disconnect_right_before_commit(self):
|
||||
with self._check_multiphase_put_commit_handling() as context:
|
||||
@ -7731,7 +7734,7 @@ class TestObjectServer(unittest.TestCase):
|
||||
if six.PY2:
|
||||
conn.sock.fd._sock.close()
|
||||
else:
|
||||
conn.sock.fd.close()
|
||||
conn.sock.fd._real_close()
|
||||
sleep(0)
|
||||
|
||||
put_timestamp = context['put_timestamp']
|
||||
@ -7775,7 +7778,7 @@ class TestObjectServer(unittest.TestCase):
|
||||
if six.PY2:
|
||||
conn.sock.fd._sock.close()
|
||||
else:
|
||||
conn.sock.fd.close()
|
||||
conn.sock.fd._real_close()
|
||||
sleep(0)
|
||||
|
||||
put_timestamp = context['put_timestamp']
|
||||
@ -7957,7 +7960,7 @@ class TestObjectServer(unittest.TestCase):
|
||||
if six.PY2:
|
||||
conn.sock.fd._sock.close()
|
||||
else:
|
||||
conn.sock.fd.close()
|
||||
conn.sock.fd._real_close()
|
||||
sleep(0)
|
||||
|
||||
# and make sure it demonstrates the client disconnect
|
||||
@ -8155,7 +8158,7 @@ class TestObjectServer(unittest.TestCase):
|
||||
if six.PY2:
|
||||
conn.sock.fd._sock.close()
|
||||
else:
|
||||
conn.sock.fd.close()
|
||||
conn.sock.fd._real_close()
|
||||
sleep(0)
|
||||
|
||||
# and make sure it demonstrates the client disconnect
|
||||
|
Loading…
Reference in New Issue
Block a user