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
9c528d80
Commit
9c528d80
authored
Jul 06, 2012
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/processes.py: use the programs that are likely to be present
parent
b3e3099e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
examples/processes.py
examples/processes.py
+6
-6
No files found.
examples/processes.py
View file @
9c528d80
...
...
@@ -5,20 +5,20 @@ from gevent import subprocess
# run 2 jobs in parallel
p1
=
subprocess
.
Popen
([
'uname'
],
stdout
=
subprocess
.
PIPE
)
p2
=
subprocess
.
Popen
([
'
finger
'
],
stdout
=
subprocess
.
PIPE
)
p2
=
subprocess
.
Popen
([
'
ls
'
],
stdout
=
subprocess
.
PIPE
)
job1
=
gevent
.
spawn
(
p1
.
stdout
.
read
)
job2
=
gevent
.
spawn
(
p2
.
stdout
.
read
)
# wait for them to complete. stop waiting after 2 seconds
gevent
.
joinall
([
job1
,
job2
],
timeout
=
5
)
gevent
.
joinall
([
job1
,
job2
],
timeout
=
2
)
# print the results (if available)
if
job1
.
ready
():
print
(
'
finger
: %s bytes: %s'
%
(
len
(
job1
.
value
or
''
),
repr
(
job1
.
value
)[:
50
]))
print
(
'
uname
: %s bytes: %s'
%
(
len
(
job1
.
value
or
''
),
repr
(
job1
.
value
)[:
50
]))
else
:
print
(
'
finger
: job is still running'
)
print
(
'
uname
: job is still running'
)
if
job2
.
ready
():
print
(
'
netstat
: %s bytes: %s'
%
(
len
(
job2
.
value
or
''
),
repr
(
job2
.
value
)[:
50
]))
print
(
'
ls
: %s bytes: %s'
%
(
len
(
job2
.
value
or
''
),
repr
(
job2
.
value
)[:
50
]))
else
:
print
(
'
netstat
: job is still running'
)
print
(
'
ls
: job is still running'
)
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