Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
EPUG
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bio-IT
EPUG
Commits
c2889e8a
Commit
c2889e8a
authored
11 years ago
by
Holger Dinkel
Browse files
Options
Downloads
Patches
Plain Diff
add multiprocessing examples using ping
parent
6764281d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
users/dinkel/multiprocessing/ping_subnet_map.py
+24
-0
24 additions, 0 deletions
users/dinkel/multiprocessing/ping_subnet_map.py
users/dinkel/multiprocessing/ping_subnet_simple.py
+22
-0
22 additions, 0 deletions
users/dinkel/multiprocessing/ping_subnet_simple.py
with
46 additions
and
0 deletions
users/dinkel/multiprocessing/ping_subnet_map.py
0 → 100755
+
24
−
0
View file @
c2889e8a
#!/usr/bin/env python
from
multiprocessing.dummy
import
Pool
#from multiprocessing import Pool
import
socket
import
subprocess
import
random
from
time
import
sleep
def
ping
(
ip
):
syscall
=
subprocess
.
Popen
([
"
ping
"
,
"
-c
"
,
"
1
"
,
"
-W
"
,
"
1
"
,
ip
],
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
syscall
.
wait
()
# sleep(random.randint(1,5))
print
'
Pinging
'
,
ip
return
ip
#syscall.returncode
if
__name__
==
'
__main__
'
:
subnet
=
'
.
'
.
join
(
socket
.
gethostbyname
(
socket
.
gethostname
()).
split
(
'
.
'
)[:
-
1
])
+
'
.
'
MAX_HOSTS
=
254
pool
=
Pool
(
100
)
net
=
[
subnet
+
str
(
i
)
for
i
in
range
(
1
,
MAX_HOSTS
)]
result
=
pool
.
map
(
ping
,
net
)
pool
.
close
()
print
result
This diff is collapsed.
Click to expand it.
users/dinkel/multiprocessing/ping_subnet_simple.py
0 → 100755
+
22
−
0
View file @
c2889e8a
#!/usr/bin/env python
import
socket
import
subprocess
def
ping
(
ip
):
print
'
Pinging
'
,
ip
syscall
=
subprocess
.
Popen
([
"
ping
"
,
"
-c
"
,
"
1
"
,
"
-W
"
,
"
1
"
,
ip
],
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
syscall
.
wait
()
return
syscall
.
returncode
if
__name__
==
'
__main__
'
:
subnet
=
'
.
'
.
join
(
socket
.
gethostbyname
(
socket
.
gethostname
()).
split
(
'
.
'
)[:
-
1
])
+
'
.
'
MAX_HOSTS
=
10
net
=
[
subnet
+
str
(
i
)
for
i
in
range
(
1
,
MAX_HOSTS
)]
print
net
for
i
in
net
:
print
ping
(
i
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment