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
bcb00e9c
Commit
bcb00e9c
authored
Dec 10, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move alarm() to util.py
parent
252c256f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
41 deletions
+21
-41
greentest/test__nondefaultloop.py
greentest/test__nondefaultloop.py
+1
-19
greentest/test__sleep0.py
greentest/test__sleep0.py
+1
-19
greentest/util.py
greentest/util.py
+19
-3
No files found.
greentest/test__nondefaultloop.py
View file @
bcb00e9c
# test for issue #210
from
gevent
import
core
import
time
import
sys
import
os
import
threading
class
alarm
(
threading
.
Thread
):
# can't use signal.alarm because of Windows
def
__init__
(
self
,
timeout
):
threading
.
Thread
.
__init__
(
self
)
self
.
setDaemon
(
True
)
self
.
timeout
=
timeout
self
.
start
()
def
run
(
self
):
time
.
sleep
(
self
.
timeout
)
sys
.
stderr
.
write
(
'Timeout.
\
n
'
)
os
.
_exit
(
5
)
from
util
import
alarm
alarm
(
1
)
...
...
greentest/test__sleep0.py
View file @
bcb00e9c
from
__future__
import
with_statement
import
gevent
import
time
import
sys
import
os
import
threading
class
alarm
(
threading
.
Thread
):
# can't use signal.alarm because of Windows
def
__init__
(
self
,
timeout
):
threading
.
Thread
.
__init__
(
self
)
self
.
setDaemon
(
True
)
self
.
timeout
=
timeout
self
.
start
()
def
run
(
self
):
time
.
sleep
(
self
.
timeout
)
sys
.
stderr
.
write
(
'Timeout.
\
n
'
)
os
.
_exit
(
5
)
from
util
import
alarm
alarm
(
1
)
...
...
greentest/util.py
View file @
bcb00e9c
...
...
@@ -4,8 +4,9 @@ import os
import
re
import
traceback
import
unittest
import
threading
import
time
from
datetime
import
timedelta
from
time
import
time
from
gevent
import
subprocess
,
sleep
,
spawn_later
...
...
@@ -168,9 +169,9 @@ def run(command, **kwargs):
popen
=
start
(
command
,
**
kwargs
)
name
=
popen
.
name
try
:
time_start
=
time
()
time_start
=
time
.
time
()
out
,
err
=
popen
.
communicate
()
took
=
time
()
-
time_start
took
=
time
.
time
()
-
time_start
if
popen
.
poll
()
is
None
:
result
=
'TIMEOUT'
else
:
...
...
@@ -388,3 +389,18 @@ class TestServer(unittest.TestCase):
function
()
ran
=
True
assert
ran
class
alarm
(
threading
.
Thread
):
# can't use signal.alarm because of Windows
def
__init__
(
self
,
timeout
):
threading
.
Thread
.
__init__
(
self
)
self
.
setDaemon
(
True
)
self
.
timeout
=
timeout
self
.
start
()
def
run
(
self
):
time
.
sleep
(
self
.
timeout
)
sys
.
stderr
.
write
(
'Timeout.
\
n
'
)
os
.
_exit
(
5
)
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