Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
s_doering
asteriskperf-python-wrapper
Commits
88ee83bc
Commit
88ee83bc
authored
Jul 11, 2015
by
Deathcrow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
threading for better synchronisation
parent
eb74803f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
wrapper.py
wrapper.py
+19
-1
No files found.
wrapper.py
View file @
88ee83bc
...
...
@@ -11,6 +11,7 @@ import re
import
signal
import
subprocess
import
tempfile
import
threading
import
time
def
parse_senders
(
sender_args
,
sender
):
...
...
@@ -116,6 +117,13 @@ def clean_up():
# i['utility_file'].close()
time
.
sleep
(
1
)
def
start_utility
(
single_sender
,
scheduled_time
):
time
.
sleep
(
abs
(
scheduled_time
-
time
.
perf_counter
()))
single_sender
[
'utility'
]
=
subprocess
.
Popen
(
single_sender
[
'utility_command'
],
stdout
=
single_sender
[
'utility_file'
])
signal
.
signal
(
signal
.
SIGINT
,
signal_handler
)
signal
.
signal
(
signal
.
SIGTERM
,
signal_handler
)
...
...
@@ -223,7 +231,17 @@ for key, i in enumerate(sender):
start_time
=
time
.
perf_counter
()
for
key
,
i
in
enumerate
(
sender
):
i
[
'utility'
]
=
subprocess
.
Popen
(
i
[
'utility_command'
],
stdout
=
i
[
'utility_file'
])
# i['utility'] = subprocess.Popen(i['utility_command'], stdout=i['utility_file'])
# try to run all senders at the same time through threading 5 seconds from now
scheduled_time
=
time
.
perf_counter
()
+
5
# StartUtilityThread(i, scheduled_time).start()
i
[
'thread'
]
=
threading
.
Thread
(
target
=
start_utility
,
args
=
(
i
,
scheduled_time
))
i
[
'thread'
].
start
()
#time.sleep(5)
for
key
,
i
in
enumerate
(
sender
):
i
[
'thread'
].
join
()
print
(
i
[
'utility'
].
args
)
if
args
.
utility
!=
"netperf"
:
...
...
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