Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD 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
FSL
fslpy
Commits
ebd4a8b5
Commit
ebd4a8b5
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
More iterations for mutex test
parent
71447b94
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_idle.py
+24
-22
24 additions, 22 deletions
tests/test_idle.py
with
24 additions
and
22 deletions
tests/test_idle.py
+
24
−
22
View file @
ebd4a8b5
...
@@ -586,39 +586,41 @@ def test_mutex():
...
@@ -586,39 +586,41 @@ def test_mutex():
@idle.mutex
@idle.mutex
def
method1
(
self
):
def
method1
(
self
):
self
.
method1start
=
time
.
time
()
self
.
method1start
=
time
.
time
()
time
.
sleep
(
0.
5
)
time
.
sleep
(
0.
01
)
self
.
method1end
=
time
.
time
()
self
.
method1end
=
time
.
time
()
@idle.mutex
@idle.mutex
def
method2
(
self
):
def
method2
(
self
):
self
.
method2start
=
time
.
time
()
self
.
method2start
=
time
.
time
()
time
.
sleep
(
0.
5
)
time
.
sleep
(
0.
01
)
self
.
method2end
=
time
.
time
()
self
.
method2end
=
time
.
time
()
t
=
[
Thing
()]
for
i
in
range
(
200
):
def
thread1
():
t
=
[
Thing
()]
t
[
0
].
method1
()
def
thread
2
():
def
thread
1
():
t
[
0
].
method
2
()
t
[
0
].
method
1
()
for
i
in
range
(
20
):
def
thread2
():
t
[
0
].
method2
()
t
[
0
].
method1start
=
None
for
i
in
range
(
10
):
t
[
0
].
method2start
=
None
t
[
0
].
method1end
=
None
t
[
0
].
method2end
=
None
t1
=
threading
.
Thread
(
target
=
thread1
)
t
[
0
].
method1start
=
None
t2
=
threading
.
Thread
(
target
=
thread2
)
t
[
0
].
method2start
=
None
t
[
0
].
method1end
=
None
t
[
0
].
method2end
=
None
t1
.
start
()
t1
=
threading
.
Thread
(
target
=
thread1
)
t2
.
start
()
t2
=
threading
.
Thread
(
target
=
thread2
)
t1
.
join
()
t2
.
join
()
# Either t1 has to start and
t1
.
start
()
# finish before t2 or vice versa
t2
.
start
()
assert
(
t
[
0
].
method2start
>
t
[
0
].
method1end
or
t1
.
join
()
t
[
0
].
method1start
>
t
[
0
].
method2end
)
t2
.
join
()
# Either t1 has to start and
# finish before t2 or vice versa
assert
(
t
[
0
].
method2start
>
t
[
0
].
method1end
or
t
[
0
].
method1start
>
t
[
0
].
method2end
)
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