Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
s_doering
asteriskperf-python-wrapper
Commits
baad53c4
Commit
baad53c4
authored
Oct 06, 2015
by
Deathcrow
Browse files
workaround for pickling bug (?)
parent
619a3927
Changes
1
Hide whitespace changes
Inline
Side-by-side
wrapper.py
View file @
baad53c4
...
...
@@ -8,6 +8,7 @@ import argparse
import
copy
import
multiprocessing
import
os
import
pickle
import
re
import
random
import
signal
...
...
@@ -154,18 +155,21 @@ def clean_up():
if
args
.
cpunetlog
!=
""
:
cpunetlog
.
terminate
()
for
i
in
sender
:
subprocess
.
Popen
([
"kill"
,
"-9"
,
i
[
'utility_data'
][
0
]])
# if i['utility'].returncode == None:
try
:
i
[
'utility'
].
kill
()
except
ProcessLookupError
:
pass
#
try:
#
i['utility'].kill()
#
except ProcessLookupError:
#
pass
# i['utility_file'].close()
time
.
sleep
(
1
)
def
start_utility
(
sender_key
,
scheduled_time
):
time
.
sleep
(
abs
(
scheduled_time
-
time
.
perf_counter
()))
return
subprocess
.
Popen
(
sender
[
sender_key
][
'utility_command'
],
process
=
subprocess
.
Popen
(
sender
[
sender_key
][
'utility_command'
],
stdout
=
sender
[
sender_key
][
'utility_file'
])
data
=
[
process
.
pid
,
process
.
args
]
return
data
...
...
@@ -318,8 +322,8 @@ with multiprocessing.Pool(len(sender)) as pool:
#time.sleep(5)
for
key
,
i
in
enumerate
(
sender
):
# i['thread'].join()
i
[
'utility'
]
=
pool_results
[
key
].
get
()
print
(
i
[
'utility
'
].
args
)
i
[
'utility
_data
'
]
=
pool_results
[
key
].
get
()
print
(
i
[
'utility
_data'
][
1
]
)
...
...
@@ -332,7 +336,7 @@ if args.utility != "netperf":
line
=
ss_file
.
readline
()
while
line
is
not
""
:
for
key
,
i
in
enumerate
(
sender
):
if
re
.
search
(
str
(
i
[
'utility
'
].
pid
),
line
):
if
re
.
search
(
str
(
i
[
'utility
_data'
][
0
]
),
line
):
start
=
re
.
search
(
i
[
'src'
],
line
).
end
()
+
1
print
(
line
[
start
:
start
+
5
])
i
[
'src_port'
]
=
line
[
start
:
start
+
5
]
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment