Commit 88c00151 authored by Denis Bilenko's avatar Denis Bilenko

kill the trailing whitespace

parent 39e69f2c
......@@ -7,10 +7,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......
......@@ -159,7 +159,7 @@ def _wait_helper(ev, fd, evtype):
def wait_reader(fileno, timeout=-1, timeout_exc=TimeoutError):
evt = core.read(fileno, _wait_helper, timeout, (getcurrent(), timeout_exc))
try:
try:
returned_ev = get_hub().switch()
assert evt is returned_ev, (evt, returned_ev)
finally:
......@@ -180,7 +180,7 @@ class _SilentException:
class timeout(object):
"""Schedule an exception to raise in the current greenlet (TimeoutError by default).
Raise an exception in the block after timeout.
with timeout(seconds[, exc]):
......
# @author Bob Ippolito
#
#
# Copyright (c) 2005-2006, Bob Ippolito
# Copyright (c) 2007, Linden Research, Inc.
# Copyright (c) 2008, Donovan Preston
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......
......@@ -49,7 +49,7 @@ def patch_all(socket=True, time=True, select=True, thread=True, os=True):
# XXX patch unittest to count switches and detect event_count and run the standard tests 2 hour
# make makefile() return GreenFile. since it uses socket's buffer, while _fileobject creates a new one 2 hour
# probably make GreenSocket be also a file and makefile() just increases refcount and returns self
# probably make GreenSocket be also a file and makefile() just increases refcount and returns self
if __name__=='__main__':
import sys
......
......@@ -760,7 +760,7 @@ class Pool(object):
# assuming the above line cannot raise
p.link(lambda p: self.sem.release())
return p
def execute_async(self, func, *args, **kwargs):
if self.sem.locked():
return spawn_greenlet(self.execute, func, *args, **kwargs)
......
......@@ -15,7 +15,7 @@ def get_fileno(obj):
def select(read_list, write_list, error_list, t=None):
hub = gevent.get_hub()
t = None
current = gevent.getcurrent()
current = gevent.getcurrent()
assert hub.greenlet is not current, 'do not call blocking functions from the mainloop'
allevents = []
......
......@@ -6,10 +6,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......@@ -565,9 +565,9 @@ class GreenSSL(GreenSocket):
self._refcount = RefCount()
read = read
def sendall(self, data):
# overriding sendall because ssl sockets behave badly when asked to
# overriding sendall because ssl sockets behave badly when asked to
# send empty strings; 'normal' sockets don't have a problem
if not data:
return
......@@ -591,7 +591,7 @@ class GreenSSL(GreenSocket):
def makefile(self, *args, **kw):
self._refcount.increment()
return GreenFile(type(self)(self.fd, refcount = self._refcount))
makeGreenFile = makefile
def close(self):
......@@ -608,7 +608,7 @@ def socketpair(*args):
def fromfd(*args):
return GreenSocket(_original_fromfd(*args))
def socket_bind_and_listen(descriptor, addr=('', 0), backlog=50):
set_reuse_addr(descriptor)
descriptor.bind(addr)
......@@ -684,7 +684,7 @@ def tcp_server(listensocket, server, *args, **kw):
try:
try:
while True:
client_socket = listensocket.accept()
client_socket = listensocket.accept()
spawn(server, client_socket, *args, **kw)
except error, e:
# Broken pipe means it was shutdown
......
......@@ -46,7 +46,7 @@ class TestCase(unittest.TestCase):
from gevent import core
gevent.sleep(0) # switch at least once to setup signal handlers
if hasattr(core, '_event_count'):
self._event_count = (core._event_count(), core._event_count_active())
self._event_count = (core._event_count(), core._event_count_active())
self._switch_count = gevent.get_hub().switch_count
self._timer = gevent.timeout(self.__timeout__, RuntimeError('test is taking too long'))
......
......@@ -141,7 +141,7 @@ class TestResult:
if self.warnings():
r += '\n' + '\n'.join(self.warnings()).replace(' ', ' ')
return r
def format(self):
text = self.text().replace('\n', '<br>\n')
if self.id is None:
......
......@@ -5,10 +5,10 @@
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......@@ -51,26 +51,26 @@ class TestGreenIo(TestCase):
self.assertRaises(socket.error, conn.send, 'b')
finally:
listener.close()
def did_it_work(server):
client = socket.connect_tcp(('127.0.0.1', server.getsockname()[1]))
fd = client.makeGreenFile()
client.close()
assert fd.readline() == 'hello\n'
assert fd.readline() == 'hello\n'
assert fd.read() == ''
fd.close()
server = socket.tcp_listener(('0.0.0.0', 0))
killer = gevent.spawn(accept_close_early, server)
did_it_work(server)
gevent.kill(killer)
server = socket.tcp_listener(('0.0.0.0', 0))
killer = gevent.spawn(accept_close_late, server)
did_it_work(server)
gevent.kill(killer)
def test_del_closes_socket(self):
timer = gevent.timeout(0.5)
def accept_once(listener):
......@@ -90,10 +90,10 @@ class TestGreenIo(TestCase):
client = socket.connect_tcp(('127.0.0.1', server.getsockname()[1]))
fd = client.makeGreenFile()
client.close()
assert fd.read() == 'hello\n'
assert fd.read() == 'hello\n'
assert fd.read() == ''
timer.cancel()
if __name__ == '__main__':
main()
......@@ -48,7 +48,7 @@ def parse_stdout(s):
if reactor is not None:
hub += '/%s' % reactor
return testname, hub
greentest_delim = '----------------------------------------------------------------------'
def parse_greentest_output(s):
......@@ -87,7 +87,7 @@ def main(db):
c.commit()
parse_error = 0
SQL = ('select command_record.id, command, stdout, exitcode from command_record '
'where not exists (select * from parsed_command_record where '
'parsed_command_record.id=command_record.id)')
......
......@@ -63,7 +63,7 @@ class TestTimers(greentest.TestCase):
self.lst = [1]
def test_timer_fired(self):
def func():
gevent.timer(0.1, self.lst.pop)
gevent.sleep(0.2)
......
......@@ -174,12 +174,12 @@ class TestQueue(TestCase):
self.assertEquals(e1.wait(), 'timed out')
self.assertEquals(e2.wait(), 'timed out')
self.assertEquals(q.wait(), 'sent')
# def test_waiting(self):
# def do_wait(q, evt):
# result = q.wait()
# evt.send(result)
#
#
# q = coros.Queue()
# e1 = coros.event()
# gevent.spawn(do_wait, q, e1)
......
......@@ -38,7 +38,7 @@ class TestSemaphore(TestCase):
spawn(sem.acquire)
sem.release()
self.assertEqual(3, sem.balance)
def test_bounded_with_zero_limit(self):
sem = coros.BoundedSemaphore(0, 0)
spawn(sem.acquire)
......
......@@ -27,7 +27,7 @@ from greentest import TestCase
DELAY= 0.01
class TestEvent(TestCase):
def test_send_exc(self):
log = []
e = event()
......
......@@ -67,10 +67,10 @@ class TestCoroutinePool(TestCase):
pool.execute_async(reenter_async)
evt.wait()
def test_stderr_raising(self):
# testing that really egregious errors in the error handling code
# (that prints tracebacks to stderr) don't cause the pool to lose
# testing that really egregious errors in the error handling code
# (that prints tracebacks to stderr) don't cause the pool to lose
# any members
import sys
pool = self.klass(size=1)
......@@ -88,7 +88,7 @@ class TestCoroutinePool(TestCase):
self.assertRaises(RuntimeError, waiter.wait)
# the pool should have something free at this point since the
# waiter returned
# pool.Pool change: if an exception is raised during execution of a link,
# pool.Pool change: if an exception is raised during execution of a link,
# the rest of the links are scheduled to be executed on the next hub iteration
# this introduces a delay in updating pool.sem which makes pool.free_count() report 0
# therefore, sleep:
......
......@@ -6,10 +6,10 @@ def server():
(client, addr) = listener.accept()
# start reading, then, while reading, start writing. the reader should not hang forever
N = 100000 # must be a big enough number so that sendall calls trampoline
proc.spawn_greenlet(client.sendall, 't' * N)
proc.spawn_greenlet(client.sendall, 't' * N)
result = client.recv(1000)
assert result == 'hello world', result
#print '%s: client' % getcurrent()
server_proc = proc.spawn(server)
......
......@@ -23,7 +23,7 @@ import greentest
from gevent import socket
class TestSocketErrors(greentest.TestCase):
def test_connection_refused(self):
s = socket.GreenSocket()
try:
......
......@@ -194,10 +194,10 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
class QueueTest(BaseQueueTest):
type2test = Queue.Queue
# class LifoQueueTest(BaseQueueTest):
# type2test = Queue.LifoQueue
#
#
# class PriorityQueueTest(BaseQueueTest):
# type2test = Queue.PriorityQueue
......
......@@ -144,7 +144,7 @@ def execf():
greentest.TestCase = TestCase
patch_greentest()
execfile(filename, globals())
while True:
#print 'before fork, %s' % disabled_tests
try:
......@@ -174,15 +174,15 @@ while True:
except Exception:
pass
print '\n===%s was killed after %s seconds' % (child, time.time()-start)
sys.stdout.flush()
sys.stdout.flush()
bad_test = None
try:
bad_test = file(CURRENT_TEST_FILENAME).read()
except IOError:
pass
pass
if bad_test in disabled_tests:
print '\n===%s was disabled but it still managed to fail?!' % bad_test
sys.stdout.flush()
sys.stdout.flush()
break
if bad_test is None:
sys.exit(7)
......
......@@ -32,13 +32,13 @@ else:
break
if not ev_dir:
sys.exit("couldn't find libevent installation or build directory")
print 'found libevent build directory', ev_dir
ev_incdirs = [ev_dir, ev_dir + '/compat']
ev_extargs = []
ev_extobjs = []
ev_libraries = ['event']
if sys.platform == 'win32':
ev_incdirs.extend(['%s/WIN32-Code' % ev_dir,
'%s/compat' % ev_dir])
......
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