Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
f3acb176
Commit
f3acb176
authored
May 11, 2017
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More pylint for examples and tests
parent
4f267154
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
37 deletions
+40
-37
examples/psycopg2_pool.py
examples/psycopg2_pool.py
+10
-10
examples/webproxy.py
examples/webproxy.py
+3
-4
examples/wsgiserver.py
examples/wsgiserver.py
+3
-3
examples/wsgiserver_ssl.py
examples/wsgiserver_ssl.py
+3
-3
src/gevent/libev/corecffi.py
src/gevent/libev/corecffi.py
+1
-0
src/greentest/greentest.py
src/greentest/greentest.py
+17
-14
src/greentest/patched_tests_setup.py
src/greentest/patched_tests_setup.py
+2
-2
src/greentest/util.py
src/greentest/util.py
+1
-1
No files found.
examples/psycopg2_pool.py
View file @
f3acb176
...
...
@@ -10,10 +10,10 @@ from psycopg2 import extensions, OperationalError, connect
if
sys
.
version_info
[
0
]
>=
3
:
integer_types
=
int
,
integer_types
=
(
int
,)
else
:
import
__builtin__
integer_types
=
int
,
__builtin__
.
long
integer_types
=
(
int
,
__builtin__
.
long
)
def
gevent_wait_callback
(
conn
,
timeout
=
None
):
...
...
@@ -50,7 +50,7 @@ class AbstractDatabaseConnectionPool(object):
pool
=
self
.
pool
if
self
.
size
>=
self
.
maxsize
or
pool
.
qsize
():
return
pool
.
get
()
else
:
self
.
size
+=
1
try
:
new_item
=
self
.
create_connection
()
...
...
examples/webproxy.py
View file @
f3acb176
...
...
@@ -104,11 +104,10 @@ def join(url1, *rest):
if
url1
.
endswith
(
b'/'
):
if
url2
.
startswith
(
b'/'
):
return
join
(
url1
+
url2
[
1
:],
*
rest
)
else
:
return
join
(
url1
+
url2
,
*
rest
)
elif
url2
.
startswith
(
b'/'
):
return
join
(
url1
+
url2
,
*
rest
)
else
:
return
join
(
url1
+
b'/'
+
url2
,
*
rest
)
...
...
examples/wsgiserver.py
View file @
f3acb176
...
...
@@ -8,7 +8,7 @@ def application(env, start_response):
if
env
[
'PATH_INFO'
]
==
'/'
:
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/html'
)])
return
[
b"<b>hello world</b>"
]
else
:
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/html'
)])
return
[
b'<h1>Not Found</h1>'
]
...
...
examples/wsgiserver_ssl.py
View file @
f3acb176
...
...
@@ -9,7 +9,7 @@ def hello_world(env, start_response):
if
env
[
'PATH_INFO'
]
==
'/'
:
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/html'
)])
return
[
b"<b>hello world</b>"
]
else
:
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/html'
)])
return
[
b'<h1>Not Found</h1>'
]
...
...
src/gevent/libev/corecffi.py
View file @
f3acb176
# pylint:disable=too-many-lines, protected-access, redefined-outer-name, not-callable,
# pylint:disable=no-member
from
__future__
import
absolute_import
,
print_function
import
sys
import
os
...
...
src/greentest/greentest.py
View file @
f3acb176
...
...
@@ -136,7 +136,7 @@ class ExpectedException(Exception):
def
wrap_switch_count_check
(
method
):
@
wraps
(
method
)
def
wrap
_switch_count_check
(
self
,
*
args
,
**
kwargs
):
def
wrap
per
(
self
,
*
args
,
**
kwargs
):
initial_switch_count
=
getattr
(
_get_hub
(),
'switch_count'
,
None
)
self
.
switch_expected
=
getattr
(
self
,
'switch_expected'
,
True
)
if
initial_switch_count
is
not
None
:
...
...
@@ -156,7 +156,7 @@ def wrap_switch_count_check(method):
else
:
raise
AssertionError
(
'Invalid value for switch_expected: %r'
%
(
self
.
switch_expected
,
))
return
result
return
wrap
_switch_count_check
return
wrap
per
def
wrap_timeout
(
timeout
,
method
):
...
...
@@ -164,11 +164,11 @@ def wrap_timeout(timeout, method):
return
method
@
wraps
(
method
)
def
wrap
_timeout
(
self
,
*
args
,
**
kwargs
):
def
wrap
per
(
self
,
*
args
,
**
kwargs
):
with
gevent
.
Timeout
(
timeout
,
'test timed out'
,
ref
=
False
):
return
method
(
self
,
*
args
,
**
kwargs
)
return
wrap
_timeout
return
wrap
per
def
ignores_leakcheck
(
func
):
func
.
ignore_leakcheck
=
True
...
...
@@ -212,7 +212,7 @@ def wrap_refcount(method):
return
diff
@
wraps
(
method
)
def
wrap
_refcount
(
self
,
*
args
,
**
kwargs
):
def
wrap
per
(
self
,
*
args
,
**
kwargs
):
gc
.
collect
()
gc
.
collect
()
gc
.
collect
()
...
...
@@ -272,12 +272,12 @@ def wrap_refcount(method):
gc
.
enable
()
self
.
skipTearDown
=
True
return
wrap
_refcount
return
wrap
per
def
wrap_error_fatal
(
method
):
@
wraps
(
method
)
def
wrap
_error_fatal
(
self
,
*
args
,
**
kwargs
):
def
wrap
per
(
self
,
*
args
,
**
kwargs
):
# XXX should also be able to do gevent.SYSTEM_ERROR = object
# which is a global default to all hubs
SYSTEM_ERROR
=
gevent
.
get_hub
().
SYSTEM_ERROR
...
...
@@ -286,12 +286,12 @@ def wrap_error_fatal(method):
return
method
(
self
,
*
args
,
**
kwargs
)
finally
:
gevent
.
get_hub
().
SYSTEM_ERROR
=
SYSTEM_ERROR
return
wrap
_error_fatal
return
wrap
per
def
wrap_restore_handle_error
(
method
):
@
wraps
(
method
)
def
wrap
_restore_handle_erro
r
(
self
,
*
args
,
**
kwargs
):
def
wrap
pe
r
(
self
,
*
args
,
**
kwargs
):
old
=
gevent
.
get_hub
().
handle_error
try
:
return
method
(
self
,
*
args
,
**
kwargs
)
...
...
@@ -299,7 +299,7 @@ def wrap_restore_handle_error(method):
gevent
.
get_hub
().
handle_error
=
old
if
self
.
peek_error
()[
0
]
is
not
None
:
gevent
.
getcurrent
().
throw
(
*
self
.
peek_error
()[
1
:])
return
wrap
_restore_handle_erro
r
return
wrap
pe
r
def
_get_class_attr
(
classDict
,
bases
,
attr
,
default
=
AttributeError
):
...
...
@@ -369,6 +369,7 @@ class TestCase(TestCaseMetaClass("NewBase", (BaseTestCase,), {})):
close_on_teardown
=
()
def
run
(
self
,
*
args
,
**
kwargs
):
# pylint:disable=arguments-differ
if
self
.
switch_expected
==
'default'
:
self
.
switch_expected
=
get_switch_expected
(
self
.
fullname
)
return
BaseTestCase
.
run
(
self
,
*
args
,
**
kwargs
)
...
...
@@ -521,6 +522,7 @@ class CountingHub(_original_Hub):
switch_count
=
0
def
switch
(
self
,
*
args
):
# pylint:disable=arguments-differ
self
.
switch_count
+=
1
return
_original_Hub
.
switch
(
self
,
*
args
)
...
...
@@ -722,7 +724,7 @@ def _run_lsof():
os
.
remove
(
tmpname
)
return
data
def
get_open_files
(
pipes
=
False
):
def
default_
get_open_files
(
pipes
=
False
):
data
=
_run_lsof
()
results
=
{}
for
line
in
data
.
split
(
'
\
n
'
):
...
...
@@ -746,7 +748,7 @@ def get_open_files(pipes=False):
results['
data
'] = data
return results
def get_number_open_files():
def
default_
get_number_open_files():
if os.path.exists('
/
proc
/
'):
# Linux only
fd_directory = '
/
proc
/%
d
/
fd
' % os.getpid()
...
...
@@ -757,12 +759,13 @@ def get_number_open_files():
except (OSError, AssertionError):
return 0
lsof_get_open_files = get_open_files
lsof_get_open_files =
default_
get_open_files
try:
import psutil
except ImportError:
pass
get_open_files = default_get_open_files
get_number_open_files = default_get_number_open_files
else:
# If psutil is available (it is cross-platform) use that.
# It is *much* faster than shelling out to lsof each time
...
...
src/greentest/patched_tests_setup.py
View file @
f3acb176
...
...
@@ -497,7 +497,7 @@ if hasattr(sys, 'pypy_version_info') and sys.version_info[:2] >= (3, 3):
]
if
hasattr
(
sys
,
'pypy_version_info'
)
and
sys
.
pypy_version_info
[:
4
]
==
(
5
,
7
,
1
,
'beta'
):
if
hasattr
(
sys
,
'pypy_version_info'
)
and
sys
.
pypy_version_info
[:
4
]
==
(
5
,
7
,
1
,
'beta'
):
# pylint:disable=no-member
# 3.5 is beta. Hard to say what are real bugs in us vs real bugs in pypy.
# For that reason, we pin these patches exactly to the version in use.
...
...
@@ -728,7 +728,7 @@ def _build_test_structure(sequence_of_tests):
disabled_tests_by_file
=
collections
.
defaultdict
(
set
)
for
file_case_meth
in
_disabled_tests
:
file_name
,
_case
,
meth
=
file_case_meth
.
split
(
'.'
)
file_name
,
_case
,
_
meth
=
file_case_meth
.
split
(
'.'
)
by_file
=
disabled_tests_by_file
[
file_name
]
...
...
src/greentest/util.py
View file @
f3acb176
...
...
@@ -193,7 +193,7 @@ def run(command, **kwargs):
finally
:
kill
(
popen
)
assert
not
err
with
lock
:
with
lock
:
# pylint:disable=not-context-manager
failed
=
bool
(
result
)
if
out
and
(
failed
or
verbose
):
out
=
out
.
strip
().
decode
(
'utf-8'
,
'ignore'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment