Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
a8a31728
Commit
a8a31728
authored
Mar 29, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Import Latch soak test
parent
15194abb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
tests/soak/latch.py
tests/soak/latch.py
+51
-0
No files found.
tests/soak/latch.py
0 → 100644
View file @
a8a31728
"""
Used for stressing Latch.get/put. Swap the number of producer/consumer threads
below to try both -- there are many conditions in the Latch code that require
testing of both.
"""
import
logging
import
random
import
threading
import
time
import
mitogen.core
import
mitogen.utils
mitogen
.
utils
.
log_to_file
()
mitogen
.
core
.
IOLOG
.
setLevel
(
logging
.
DEBUG
)
mitogen
.
core
.
_v
=
True
mitogen
.
core
.
_vv
=
True
l
=
mitogen
.
core
.
Latch
()
consumed
=
0
produced
=
0
crash
=
0
def
cons
():
global
consumed
,
crash
try
:
while
1
:
g
=
l
.
get
()
print
'got=%s consumed=%s produced=%s crash=%s'
%
(
g
,
consumed
,
produced
,
crash
)
consumed
+=
1
time
.
sleep
(
g
)
for
x
in
xrange
(
int
(
g
*
1000
)):
pass
except
:
crash
+=
1
def
prod
():
global
produced
while
1
:
l
.
put
(
random
.
random
()
/
10
)
produced
+=
1
time
.
sleep
(
random
.
random
()
/
10
)
allc
=
[
threading
.
Thread
(
target
=
cons
)
for
x
in
range
(
64
)]
allp
=
[
threading
.
Thread
(
target
=
prod
)
for
x
in
range
(
8
)]
for
th
in
allc
+
allp
:
th
.
setDaemon
(
True
)
th
.
start
()
raw_input
()
exit
()
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