Commit 9472b008 authored by Mark Peek's avatar Mark Peek

pep8

parent 0559e618
......@@ -69,12 +69,12 @@ def main():
global exit_code
try:
try:
#p = unittest.TestProgram(runNow=False)
# p = unittest.TestProgram(runNow=False)
p = unittest.TestProgram()
# This should always be the last test case run.
p.test.addTest(ThreadFailedTest('test_threads_failed'))
p.runTests()
except SystemExit, e:
except SystemExit as e:
exit_code = e.code
finally:
coro.set_exit(exit_code)
......
......@@ -19,7 +19,7 @@ class TestServer:
self.port = self.s.getsockname()[1]
self.s.set_reuse_addr()
self.s.listen (5)
while 1:
while True:
try:
coro.write_stderr ('accepting...\n')
conns = self.s.accept_many (5)
......
......@@ -66,9 +66,9 @@ class Test(unittest.TestCase):
coro.aio_write(self.fd, orig_data, 0)
for x in xrange(100):
size = random.randint(1, filesize)
offset = random.randint(0, filesize-size)
offset = random.randint(0, filesize - size)
data = coro.aio_read(self.fd, size, offset)
self.assertEqual(data, orig_data[offset:offset+size])
self.assertEqual(data, orig_data[offset:offset + size])
os.close(self.fd)
......@@ -84,9 +84,9 @@ class Test(unittest.TestCase):
coro.aio_write(self.fd, orig_data, 0)
for x in xrange(100):
size = random.randint(1, filesize)
offset = random.randint(0, filesize-size)
offset = random.randint(0, filesize - size)
data = coro.aio_read(self.fd, size, offset)
self.assertEqual(data, orig_data[offset:offset+size])
self.assertEqual(data, orig_data[offset:offset + size])
self.assertEqual(event_size, len(coro.event_map))
......@@ -95,7 +95,7 @@ class Test(unittest.TestCase):
for x in xrange(100):
size = random.randint(1, filesize)
offset = random.randint(0, filesize-size)
offset = random.randint(0, filesize - size)
self.assertRaises(OSError, coro.aio_read, self.fd, size, offset)
self.assertEqual(event_size, len(coro.event_map))
......
......@@ -33,22 +33,22 @@ class Test(unittest.TestCase):
return num
self.assertRaises(coro.TimeoutError,
coro.with_timeout,
2,
coro.in_parallel,
[(sleeper, (1,)),
(sleeper, (2,)),
(sleeper, (3,)),
]
)
coro.with_timeout,
2,
coro.in_parallel,
[(sleeper, (1,)),
(sleeper, (2,)),
(sleeper, (3,)),
]
)
results = coro.with_timeout(7, coro.in_parallel,
[(sleeper, (4,)),
(sleeper, (5,)),
(sleeper, (6,)),
]
)
self.assertEqual(results, [4,5,6])
[(sleeper, (4,)),
(sleeper, (5,)),
(sleeper, (6,)),
]
)
self.assertEqual(results, [4, 5, 6])
if __name__ == '__main__':
coro_unittest.run_tests()
......@@ -31,8 +31,9 @@ class Test(unittest.TestCase):
def test_scheduled_staging_interrupt(self):
"""Test interrupting a thread that is scheduled and in the staging list."""
t = coro.get_now() + coro.ticks_per_sec*3
t = coro.get_now() + coro.ticks_per_sec * 3
exception_raised = [False]
def foo():
self.assertFalse(exception_raised[0])
try:
......@@ -49,6 +50,7 @@ class Test(unittest.TestCase):
def test_scheduled_pending_interrupt(self):
"""Test interrupting a thread that is scheduled and in the pending list."""
exception_raised = [False]
def foo():
self.assertFalse(exception_raised[0])
try:
......@@ -66,6 +68,7 @@ class Test(unittest.TestCase):
def test_interrupt_sleeping_coro(self):
"""Test interrupting a thread in a sleep call."""
exception_raised = [False]
def foo():
self.assertFalse(exception_raised[0])
try:
......@@ -109,7 +112,7 @@ class Test(unittest.TestCase):
expires.
"""
self.assertRaises(coro.TimeoutError,
coro.with_timeout, 0, coro.sleep_relative, 0)
coro.with_timeout, 0, coro.sleep_relative, 0)
if __name__ == '__main__':
......
......@@ -30,6 +30,7 @@ import operator
import os
import tempfile
import unittest
from functools import reduce
class Test(unittest.TestCase):
......@@ -47,28 +48,28 @@ class Test(unittest.TestCase):
def test_read_write(self):
"""Test read/write."""
self.fd = os.open('test_lio_file', os.O_RDWR|os.O_CREAT|os.O_TRUNC)
self.fd = os.open('test_lio_file', os.O_RDWR | os.O_CREAT | os.O_TRUNC)
# Simple 1-byte test.
self._read_write(['a'])
# Test 3 blocks in 1 batch.
data = [ os.urandom(coro.MAX_AIO_SIZE),
os.urandom(coro.MAX_AIO_SIZE),
os.urandom(int(coro.MAX_AIO_SIZE * 0.6)),
]
data = [os.urandom(coro.MAX_AIO_SIZE),
os.urandom(coro.MAX_AIO_SIZE),
os.urandom(int(coro.MAX_AIO_SIZE * 0.6)),
]
self._read_write(data)
# Test various numbers of full batches.
for n in xrange(1, 5):
data = [ os.urandom(coro.MAX_AIO_SIZE) for x in xrange(coro.MAX_LIO*n) ]
data = [os.urandom(coro.MAX_AIO_SIZE) for x in xrange(coro.MAX_LIO * n)]
self._read_write(data)
# Test offset read/write.
data = [ os.urandom(coro.MAX_AIO_SIZE) for x in xrange(3) ]
data = [os.urandom(coro.MAX_AIO_SIZE) for x in xrange(3)]
total_bytes = reduce(operator.add, map(len, data))
coro.many_lio_writes(self.fd, 0, data)
a = coro.many_lio_reads(self.fd, 512, total_bytes-512)
a = coro.many_lio_reads(self.fd, 512, total_bytes - 512)
expected_data = ''.join(data)[512:]
actual_data = ''.join(a)
self.assertEqual(actual_data, expected_data)
......
......@@ -42,7 +42,6 @@ class Test(unittest.TestCase):
self.t1_cv.wait()
self.assertEqual(self.shared.x, 2)
def t2(self):
self.assertFalse(hasattr(self.shared, 'x'))
self.assertRaises(AttributeError, lambda: self.shared.x)
......
......@@ -31,13 +31,13 @@ class Test (unittest.TestCase):
d[1] = 2
d[2] = 3
d[3] = 4
#print 'del[2]'
# print 'del[2]'
del d[2]
#print 'del[1]'
# print 'del[1]'
del d[1]
#print 'del[3]'
# print 'del[3]'
del d[3]
#print 'del[0]'
# print 'del[0]'
del d[0]
self.assertEqual (len(d), 0)
......
......@@ -46,7 +46,7 @@ class Test(unittest.TestCase):
self._dummy_thread.join()
def _echo(self, sock):
while 1:
while True:
try:
try:
data = sock.recv(1024)
......@@ -60,7 +60,7 @@ class Test(unittest.TestCase):
sock.send(data)
def _dummy_listener(self, s):
while 1:
while True:
sock, addr = s.accept()
self._echo_socket = sock
self._echo_thread = coro.spawn(self._echo, sock)
......@@ -77,7 +77,7 @@ class Test(unittest.TestCase):
def _blocker_thread(self):
self._blocker_socket = coro.tcp_sock()
self._blocker_socket.connect(('127.0.0.1', self.port))
while 1:
while True:
coro.print_stderr('reading')
try:
self._blocker_socket.read(1024)
......@@ -139,10 +139,10 @@ class Test(unittest.TestCase):
coro.set_handler((f.fileno(), coro.EVFILT.VNODE),
self._fired_closer,
fflags=coro.NOTE.DELETE
)
)
t2 = coro.spawn(self._fired_blocker)
#t2.set_max_selfish_acts(1)
# t2.set_max_selfish_acts(1)
# Yield to allow fired blocker to block.
coro.yield_slice()
# Now, cause threads blocked on kevents to get scheduled in a specific
......
......@@ -31,9 +31,11 @@ class Test(unittest.TestCase):
def test_wait_for_interrupt_new(self):
# Test KEVENT_STATUS_NEW
proc = coro_process.spawn_job_bg('sleep 30')
def waiter():
proc.wait()
waiter_thread = coro.spawn(waiter)
def killer():
waiter_thread.shutdown()
coro.spawn(killer)
......@@ -51,6 +53,7 @@ class Test(unittest.TestCase):
def test_wait_for_interrupt_submitted(self):
# Test KEVENT_STATUS_SUBMITTED
proc = coro_process.spawn_job_bg('sleep 30')
def waiter():
proc.wait()
waiter_thread = coro.spawn(waiter)
......@@ -112,6 +115,5 @@ class Test(unittest.TestCase):
os.close(write_fd2)
if __name__ == '__main__':
coro_unittest.run_tests()
......@@ -31,27 +31,27 @@ import coro.print_profile
import coro_unittest
# Sam's favorite profile function.
def tak1 (x,y,z):
def tak1 (x, y, z):
coro.yield_slice()
if y >= x:
return z
else:
return tak1 (
tak1 (x-1, y, z),
tak2 (y-1, z, x),
tak2 (z-1, x, y)
)
tak1 (x - 1, y, z),
tak2 (y - 1, z, x),
tak2 (z - 1, x, y)
)
def tak2 (x,y,z):
def tak2 (x, y, z):
coro.yield_slice()
if y >= x:
return z
else:
return tak2 (
tak2 (x-1, y, z),
tak1 (y-1, z, x),
tak1 (z-1, x, y)
)
tak2 (x - 1, y, z),
tak1 (y - 1, z, x),
tak1 (z - 1, x, y)
)
def multi_test():
t1 = coro.spawn(tak2, 18, 12, 6)
......
......@@ -22,7 +22,7 @@ class buffered_stream:
"generate pieces of input up to and including <delim>, then StopIteration"
ld = len(delim)
m = 0
while 1:
while True:
if self.pos == len(self.buffer):
self.buffer = self.producer()
self.pos = 0
......@@ -36,8 +36,8 @@ class buffered_stream:
if self.buffer[i] == delim[m]:
m += 1
if m == ld:
yield self.buffer[self.pos:i+1]
self.pos = i+1
yield self.buffer[self.pos:i + 1]
self.pos = i + 1
return
else:
m = 0
......@@ -48,7 +48,7 @@ class buffered_stream:
def read_until (self, delim, join=True):
"read until <delim>. return a list of parts unless <join> is True"
result = ( x for x in self.gen_read_until (delim) )
result = (x for x in self.gen_read_until (delim))
if join:
return ''.join (result)
else:
......@@ -106,7 +106,7 @@ def str_prod (s, lo, hi=None):
size = lo
else:
size = R (lo, hi)
yield s[i:i+size]
yield s[i:i + size]
i += size
import re
......@@ -115,7 +115,7 @@ data_re = re.compile ('^0+$')
def read_lines (g, delim):
r = []
ld = len(delim)
while 1:
while True:
line = g.read_line (delim)
if not line:
break
......@@ -139,10 +139,10 @@ class Test (unittest.TestCase):
t0 = self.t_line_0
print ' fixed size, small'
for i in range (1, 20):
t0 (lines0, delim, i, i+1)
t0 (lines0, delim, i, i + 1)
print ' random size, small'
for i in range (1, 20):
t0 (lines0, delim, i, i+20)
t0 (lines0, delim, i, i + 20)
print ' 1000 byte buffer'
t0 (lines0, delim, 1000, None)
print ' 10000 byte buffer'
......
......@@ -39,7 +39,7 @@ class TestServer:
self.port = self.s.getsockname()[1]
self.s.set_reuse_addr()
self.s.listen(5)
while 1:
while True:
try:
s, addr = self.s.accept()
except coro.Shutdown:
......@@ -96,10 +96,64 @@ class Test(unittest.TestCase):
# Do it once without sleeps, once with sleeps.
for sleep in (False, True):
do_sleeps = sleep
testit(family, address, (5, 19, 3, 8), (5, 19, 3, 8), ('01234', '0123456789012345678', '012', '01234567'))
testit(
family,
address,
(5,
19,
3,
8),
(5,
19,
3,
8),
('01234',
'0123456789012345678',
'012',
'01234567'))
testit(family, address, (5, 19, 3, 8), (24, 3, 8), ('012340123456789012345678', '012', '01234567'))
testit(family, address, (5, 19, 3, 8), (2, 3, 19, 3, 8), ('01', '234', '0123456789012345678', '012', '01234567'))
testit(family, address, (5, 5), (1, 1, 1, 1, 1, 1, 1, 1, 1, 1), ('0', '1', '2', '3', '4', '0', '1', '2', '3', '4'))
testit(
family,
address,
(5,
19,
3,
8),
(2,
3,
19,
3,
8),
('01',
'234',
'0123456789012345678',
'012',
'01234567'))
testit(
family,
address,
(5,
5),
(1,
1,
1,
1,
1,
1,
1,
1,
1,
1),
('0',
'1',
'2',
'3',
'4',
'0',
'1',
'2',
'3',
'4'))
testit(family, address, (1, 1, 1, 1, 1, 1, 1, 1, 1, 1), (5, 5), ('00000', '00000'))
testit(family, address, (10,), (5,), ('01234',))
testit(family, address, (5,), (10,), ('01234',))
......@@ -109,7 +163,7 @@ class Test(unittest.TestCase):
testit(family, address, (5, 9), (5, 5, 3, 7), ('01234', '01234', '567', '8'))
testit(family, address, (5, 5), (5, 5, 10), ('01234', '01234'))
testit(family, address, (5,), (6,), ('01234',))
testit(family, address, (512*1024,), (512*1024,), (big_block[:512*1024],))
testit(family, address, (512 * 1024,), (512 * 1024,), (big_block[:512 * 1024],))
server_thread.raise_exception(coro.Shutdown)
......
......@@ -101,12 +101,14 @@ class Test(unittest.TestCase):
# Pyrex had a bug where if it raised an exception it would stomp on
# the "current" exception on the Python stack.
s = coro.semaphore(0)
def blocker():
s.acquire(1)
t1 = coro.spawn(blocker)
coro.yield_slice()
# Mark the thread as scheduled.
t1.shutdown()
def raiser():
try:
raise ValueError(3)
......@@ -125,6 +127,7 @@ class Test(unittest.TestCase):
# and that function raised and caught an exception, it would stomp on
# the current exception, so re-raising would raise the wrong exception.
s = coro.semaphore(0)
def blocker():
s.acquire(1)
t1 = coro.spawn(blocker)
......
......@@ -51,7 +51,7 @@ class TestSession:
def run(self):
current_buffer = ''
while 1:
while True:
block = self.s.recv(1024)
if not block:
break
......@@ -108,40 +108,40 @@ class Test(unittest.TestCase):
def test_bind_empty_ip_v4(self):
sock = coro.make_socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("",5010))
sock.bind(("", 5010))
self.assertEquals(sock.domain, socket.AF_INET)
def test_bind_empty_ip_v6(self):
sock = coro.make_socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.bind(("",5010))
sock.bind(("", 5010))
self.assertEquals(sock.domain, socket.AF_INET6)
def test_bind_wrong_af_4to6(self):
sock = coro.make_socket(socket.AF_INET, socket.SOCK_STREAM)
self.assertEquals(sock.domain, socket.AF_INET)
self.assertRaises(ValueError, sock.bind, (("2001::1",5010),))
self.assertRaises(ValueError, sock.bind, (("2001::1", 5010),))
def test_bind_wrong_af_6to4(self):
sock = coro.make_socket(socket.AF_INET6, socket.SOCK_STREAM)
self.assertEquals(sock.domain, socket.AF_INET6)
self.assertRaises(ValueError, sock.bind, (("1.1.1.1",5010),))
self.assertRaises(ValueError, sock.bind, (("1.1.1.1", 5010),))
def test_bind_af_unspec(self):
sock = coro.make_socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.domain = socket.AF_UNSPEC
self.assertRaises(ValueError, sock.bind, (("1.1.1.1",5010),))
self.assertRaises(ValueError, sock.bind, (("",5010),))
self.assertRaises(ValueError, sock.bind, (("1.1.1.1", 5010),))
self.assertRaises(ValueError, sock.bind, (("", 5010),))
def test_getsockname_v4(self):
sock = coro.make_socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("",5555))
sock.bind(("", 5555))
sn = sock.getsockname()
self.assertEquals(sn[0], "0.0.0.0")
self.assertEquals(sn[1], 5555)
def test_getsockname_v6(self):
sock = coro.make_socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.bind(("",5555))
sock.bind(("", 5555))
sn = sock.getsockname()
self.assertEquals(sn[0], "::")
self.assertEquals(sn[1], 5555)
......
......@@ -21,7 +21,7 @@
"""Unittests for the tsc_time module."""
import struct
#import sysctl
# import sysctl
import time
import unittest
from coro.clocks import tsc_time
......@@ -29,7 +29,7 @@ from coro.clocks import tsc_time
class Test(unittest.TestCase):
# Stub test until we have a working sysctl
#def test_ticks_per_sec(self):
# def test_ticks_per_sec(self):
# freq = struct.unpack('I', sysctl.sysctl('machdep.tsc_freq'))[0]
# self.assertEqual(freq,
# tsc_time.ticks_per_sec
......@@ -59,35 +59,35 @@ class Test(unittest.TestCase):
self._assert_close(now_t,
tsc_time.usec_to_ticks(now_up),
ticks_close
)
)
self._assert_close(now_up,
tsc_time.ticks_to_usec(now_t),
up_close
)
)
self._assert_close(now_t,
tsc_time.usec_to_ticks_safe(now_up),
ticks_close
)
)
self._assert_close(now_up,
tsc_time.ticks_to_usec_safe(now_t),
up_close
)
)
self._assert_close(now_t,
tsc_time.sec_to_ticks(now_p),
tsc_time.ticks_per_sec
)
)
self._assert_close(now_p,
tsc_time.ticks_to_sec(now_t),
p_close
)
)
self._assert_close(now_fp,
tsc_time.ticks_to_fsec(now_t),
fp_close
)
)
self._assert_close(now_t,
tsc_time.fsec_to_ticks(now_fp),
ticks_close
)
)
def test_time_methods(self):
t = tsc_time.now_tsc()
......@@ -110,8 +110,8 @@ class Test(unittest.TestCase):
self.assert_(t < t2)
self.assert_(t.tsc + 1 > t)
self.assert_(t.tsc - 1 < t)
self.assert_(t.tsc + 1L > t)
self.assert_(t.tsc - 1L < t)
self.assert_(t.tsc + 1 > t)
self.assert_(t.tsc - 1 < t)
# Floating point uses larger numbers because of a loss in precision
# when converting to floating point, ex:
# >>> float(28536304964998994L)
......@@ -127,8 +127,8 @@ class Test(unittest.TestCase):
self.assert_(t < t2)
self.assert_(int(t) + 1 > t)
self.assert_(int(t) - 1 < t)
self.assert_(int(t) + 1L > t)
self.assert_(int(t) - 1L < t)
self.assert_(int(t) + 1 > t)
self.assert_(int(t) - 1 < t)
self.assert_(int(t) + 1.0 > t)
self.assert_(int(t) - 1.0 < t)
......@@ -140,8 +140,8 @@ class Test(unittest.TestCase):
self.assert_(t < t2)
self.assert_(int(t) + 1 > t)
self.assert_(int(t) - 1 < t)
self.assert_(int(t) + 1L > t)
self.assert_(int(t) - 1L < t)
self.assert_(int(t) + 1 > t)
self.assert_(int(t) - 1 < t)
self.assert_(int(t) + 1.0 > t)
self.assert_(int(t) - 1.0 < t)
......@@ -153,8 +153,8 @@ class Test(unittest.TestCase):
self.assert_(t < t2)
self.assert_(int(t) + 1 > t)
self.assert_(int(t) - 1 < t)
self.assert_(int(t) + 1L > t)
self.assert_(int(t) - 1L < t)
self.assert_(int(t) + 1 > t)
self.assert_(int(t) - 1 < t)
self.assert_(int(t) + 1.0 > t)
self.assert_(int(t) - 1.0 < t)
......@@ -163,14 +163,14 @@ class Test(unittest.TestCase):
self.assertEqual(t + 1, t.tsc + 1)
self.assertEqual(t - 1, t.tsc - 1)
self.assertEqual(t + 1L, t.tsc + 1)
self.assertEqual(t - 1L, t.tsc - 1)
self.assertEqual(t + 1, t.tsc + 1)
self.assertEqual(t - 1, t.tsc - 1)
# Removing floating point comparison because large floating point
# numbers loose precision, ex:
# >>> float(28536304964998994L)
# 28536304964998992.0
#self.assertEqual(t + 1.0, t.tsc + 1)
#self.assertEqual(t - 1.0, t.tsc - 1)
# self.assertEqual(t + 1.0, t.tsc + 1)
# self.assertEqual(t - 1.0, t.tsc - 1)
self.assertRaises(TypeError, lambda: t + 'hi')
self.assertRaises(TypeError, lambda: t - 'hi')
......@@ -178,8 +178,8 @@ class Test(unittest.TestCase):
self.assertEqual(t + 1, t.as_posix_sec() + 1)
self.assertEqual(t - 1, t.as_posix_sec() - 1)
self.assertEqual(t + 1L, t.as_posix_sec() + 1)
self.assertEqual(t - 1L, t.as_posix_sec() - 1)
self.assertEqual(t + 1, t.as_posix_sec() + 1)
self.assertEqual(t - 1, t.as_posix_sec() - 1)
self.assertEqual(t + 1.0, t.as_posix_sec() + 1)
self.assertEqual(t - 1.0, t.as_posix_sec() - 1)
self.assertRaises(TypeError, lambda: t + 'hi')
......@@ -189,8 +189,8 @@ class Test(unittest.TestCase):
self.assertEqual(t + 1, t.as_posix_usec() + 1)
self.assertEqual(t - 1, t.as_posix_usec() - 1)
self.assertEqual(t + 1L, t.as_posix_usec() + 1)
self.assertEqual(t - 1L, t.as_posix_usec() - 1)
self.assertEqual(t + 1, t.as_posix_usec() + 1)
self.assertEqual(t - 1, t.as_posix_usec() - 1)
self.assertEqual(t + 1.0, t.as_posix_usec() + 1)
self.assertEqual(t - 1.0, t.as_posix_usec() - 1)
self.assertRaises(TypeError, lambda: t + 'hi')
......@@ -202,8 +202,8 @@ class Test(unittest.TestCase):
# Python's conversions.
self._assert_close(t + 1, t.as_posix_fsec() + 1, 0.001)
self._assert_close(t - 1, t.as_posix_fsec() - 1, 0.001)
self._assert_close(t + 1L, t.as_posix_fsec() + 1, 0.001)
self._assert_close(t - 1L, t.as_posix_fsec() - 1, 0.001)
self._assert_close(t + 1, t.as_posix_fsec() + 1, 0.001)
self._assert_close(t - 1, t.as_posix_fsec() - 1, 0.001)
self._assert_close(t + 1.0, t.as_posix_fsec() + 1, 0.001)
self._assert_close(t - 1.0, t.as_posix_fsec() - 1, 0.001)
self.assertRaises(TypeError, lambda: t + 'hi')
......@@ -291,15 +291,15 @@ class Test(unittest.TestCase):
self._assert_close(ago.as_posix_sec(),
now_tsc.as_posix_sec() - 10 * 60,
1
)
)
self._assert_close(ago.as_posix_usec(),
now_tsc.as_posix_usec() - 10 * 60 * 1000000,
1000000
)
)
self._assert_close(ago.as_posix_fsec(),
now_tsc.as_posix_fsec() - 10 * 60,
0.3
)
)
# Microseconds in 1 year.
diff = long(365 * 24 * 60 * 60 * 1000000)
......@@ -309,7 +309,7 @@ class Test(unittest.TestCase):
self._assert_close(now_usec.as_posix_usec() - diff,
ago.as_posix_usec(),
10
)
)
year_ago = now_usec.as_posix_usec() - diff
year_ago_tsc = tsc_time.TSC_from_posix_usec(year_ago)
......@@ -317,7 +317,7 @@ class Test(unittest.TestCase):
self._assert_close(year_ago_tsc.as_posix_usec(),
year_ago,
10
)
)
if __name__ == '__main__':
......
......@@ -42,7 +42,7 @@ class TestServer:
self.port = self.s.getsockname()[1]
self.s.set_reuse_addr()
self.s.listen(5)
while 1:
while True:
try:
s, addr = self.s.accept()
except coro.Shutdown:
......@@ -60,7 +60,7 @@ class TestSession:
global current_buffer, finished
current_buffer = ''
received = 0
while 1:
while True:
block = self.s.recv(1024)
if not block:
break
......@@ -83,7 +83,7 @@ class Test(unittest.TestCase):
s = coro.make_socket(family, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, send_buffer_size)
coro.with_timeout(5, s.connect, (address, server.port))
blocks = [ big_block[:size] for size in block_sends ]
blocks = [big_block[:size] for size in block_sends]
rc = coro.with_timeout(5, s.writev, blocks)
s.close()
if finished is not None:
......@@ -115,7 +115,7 @@ class Test(unittest.TestCase):
testit(family, address, (5, 3, 7, 8), '01234012012345601234567', 23)
# bufsize==1 is too slow and not necessary
if bufsize != 1:
testit(family, address, (512 * 1024,), big_block[:512*1024], 512*1024)
testit(family, address, (512 * 1024,), big_block[:512 * 1024], 512 * 1024)
server_thread.raise_exception(coro.Shutdown)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment