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

pyflakes fixes

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