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
88c00151
Commit
88c00151
authored
Jul 09, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kill the trailing whitespace
parent
39e69f2c
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
52 additions
and
52 deletions
+52
-52
examples/echoserver.py
examples/echoserver.py
+2
-2
gevent/__init__.py
gevent/__init__.py
+2
-2
gevent/backdoor.py
gevent/backdoor.py
+4
-4
gevent/monkey.py
gevent/monkey.py
+1
-1
gevent/proc.py
gevent/proc.py
+1
-1
gevent/select.py
gevent/select.py
+1
-1
gevent/socket.py
gevent/socket.py
+7
-7
greentest/__init__.py
greentest/__init__.py
+1
-1
greentest/generate_report.py
greentest/generate_report.py
+1
-1
greentest/greenio_test.py
greentest/greenio_test.py
+10
-10
greentest/parse_results.py
greentest/parse_results.py
+2
-2
greentest/test__api.py
greentest/test__api.py
+1
-1
greentest/test__coros_queue.py
greentest/test__coros_queue.py
+2
-2
greentest/test__coros_semaphore.py
greentest/test__coros_semaphore.py
+1
-1
greentest/test__event.py
greentest/test__event.py
+1
-1
greentest/test__proc_pool.py
greentest/test__proc_pool.py
+4
-4
greentest/test__socket.py
greentest/test__socket.py
+2
-2
greentest/test__socket_errors.py
greentest/test__socket_errors.py
+1
-1
greentest/test_queue.py
greentest/test_queue.py
+2
-2
greentest/with_timeout.py
greentest/with_timeout.py
+4
-4
setup.py
setup.py
+2
-2
No files found.
examples/echoserver.py
View file @
88c00151
...
...
@@ -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
...
...
gevent/__init__.py
View file @
88c00151
...
...
@@ -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]):
...
...
gevent/backdoor.py
View file @
88c00151
# @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
...
...
gevent/monkey.py
View file @
88c00151
...
...
@@ -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
...
...
gevent/proc.py
View file @
88c00151
...
...
@@ -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
)
...
...
gevent/select.py
View file @
88c00151
...
...
@@ -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
=
[]
...
...
gevent/socket.py
View file @
88c00151
...
...
@@ -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
...
...
greentest/__init__.py
View file @
88c00151
...
...
@@ -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'
))
...
...
greentest/generate_report.py
View file @
88c00151
...
...
@@ -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
:
...
...
greentest/greenio_test.py
View file @
88c00151
...
...
@@ -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
()
greentest/parse_results.py
View file @
88c00151
...
...
@@ -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
)
')
...
...
greentest/test__api.py
View file @
88c00151
...
...
@@ -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
)
...
...
greentest/test__coros_queue.py
View file @
88c00151
...
...
@@ -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)
...
...
greentest/test__coros_semaphore.py
View file @
88c00151
...
...
@@ -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
)
...
...
greentest/test__event.py
View file @
88c00151
...
...
@@ -27,7 +27,7 @@ from greentest import TestCase
DELAY
=
0.01
class
TestEvent
(
TestCase
):
def
test_send_exc
(
self
):
log
=
[]
e
=
event
()
...
...
greentest/test__proc_pool.py
View file @
88c00151
...
...
@@ -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:
...
...
greentest/test__socket.py
View file @
88c00151
...
...
@@ -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
)
...
...
greentest/test__socket_errors.py
View file @
88c00151
...
...
@@ -23,7 +23,7 @@ import greentest
from
gevent
import
socket
class
TestSocketErrors
(
greentest
.
TestCase
):
def
test_connection_refused
(
self
):
s
=
socket
.
GreenSocket
()
try
:
...
...
greentest/test_queue.py
View file @
88c00151
...
...
@@ -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
...
...
greentest/with_timeout.py
View file @
88c00151
...
...
@@ -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
)
...
...
setup.py
View file @
88c00151
...
...
@@ -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
])
...
...
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