Commit 54d409df authored by Denis Bilenko's avatar Denis Bilenko

pyflakes fixes

parent c655ef40
......@@ -141,6 +141,7 @@ class AsyncResult(object):
:class:`AsyncResult` implements :meth:`__call__` and thus can be used as :meth:`link` target:
>>> import gevent
>>> result = AsyncResult()
>>> gevent.spawn(lambda : 1/0).link(result)
>>> result.get()
......
......@@ -31,7 +31,8 @@ class Timeout(BaseException):
When *exception* is omitted or ``None``, the :class:`Timeout` instance itself is raised:
>>> Timeout(0.1).start()
>>> import gevent
>>> gevent.Timeout(0.1).start()
>>> gevent.sleep(0.2)
Traceback (most recent call last):
...
......@@ -39,7 +40,7 @@ class Timeout(BaseException):
For Python 2.5 and newer ``with`` statement can be used::
with Timeout(seconds, exception) as timeout:
with gevent.Timeout(seconds, exception) as timeout:
pass # ... code block ...
This is equivalent to try/finally block above with one additional feature:
......@@ -49,7 +50,7 @@ class Timeout(BaseException):
This is handy for adding a timeout to the functions that don't support *timeout* parameter themselves::
data = None
with Timeout(5, False):
with gevent.Timeout(5, False):
data = mysock.makefile().readline()
if data is None:
... # 5 seconds passed without reading a line
......
......@@ -6,12 +6,8 @@ import random
from time import time
def init():
global N, counter
N = 10000
counter = 0
init()
N = 10000
counter = 0
def incr(sleep, **kwargs):
......
......@@ -439,7 +439,7 @@ class BaseSemaphoreTests(BaseTestCase):
def test_acquire_contended(self):
sem = self.semtype(7)
sem.acquire()
N = 10
#N = 10
results1 = []
results2 = []
phase_num = 0
......
......@@ -318,6 +318,7 @@ class TestPoolSpawn(TestDefaultSpawn):
# to let /short request finish
gevent.sleep(0.1)
self.assertRequestSucceeded()
del long_request
test_pool_full.error_fatal = False
......
......@@ -49,13 +49,13 @@ def log_fresult(result, seconds):
msg = ' -=> raised %r' % (result, )
else:
msg = ' -=> returned %r' % (result, )
time = ' %.2fms' % (seconds * 1000.0, )
space = 80 - len(msg) - len(time)
time_ms = ' %.2fms' % (seconds * 1000.0, )
space = 80 - len(msg) - len(time_ms)
if space > 0:
space = ' ' * space
else:
space = ''
log(msg + space + time)
log(msg + space + time_ms)
def run(function, *args):
......
......@@ -130,7 +130,7 @@ class Test(greentest.TestCase):
def test_issue148(self):
for i in range(7):
try:
p1 = subprocess.Popen('this_name_must_not_exist')
subprocess.Popen('this_name_must_not_exist')
except OSError as ex:
if ex.errno != errno.ENOENT:
raise
......
......@@ -261,7 +261,6 @@ except IOError:
try:
fp = open(TMP_TESTFN, 'w+')
TESTFN = TMP_TESTFN
del TMP_TESTFN
except IOError:
print ('WARNING: tests will fail, unable to write to: %s or %s' %
(TESTFN, TMP_TESTFN))
......
......@@ -289,6 +289,8 @@ class ThreadTests(unittest.TestCase):
print("test_finalize_with_runnning_thread can't import ctypes")
return # can't do anything
del ctypes # pyflakes fix
import subprocess
rc = subprocess.call([sys.executable, "-c", """if 1:
%s
......
......@@ -9,6 +9,7 @@ import pipes
import difflib
from hashlib import md5
do_exec = None
if sys.version_info >= (3, 0):
exec("def do_exec(co, loc): exec(co, loc)\n")
else:
......
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