Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
3ddd9709
Commit
3ddd9709
authored
Jul 15, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More exception tests
parent
213aeab7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
0 deletions
+105
-0
tests/run/parallel.pyx
tests/run/parallel.pyx
+25
-0
tests/run/sequential_parallel.pyx
tests/run/sequential_parallel.pyx
+80
-0
No files found.
tests/run/parallel.pyx
View file @
3ddd9709
...
...
@@ -44,5 +44,30 @@ def test_num_threads():
return
num_threads
def
test_parallel_catch
():
"""
>>> test_parallel_catch()
True
"""
cdef
int
i
,
j
,
num_threads
exceptions
=
[]
for
i
in
prange
(
100
,
nogil
=
True
,
num_threads
=
4
):
num_threads
=
openmp
.
omp_get_num_threads
()
with
gil
:
try
:
for
j
in
prange
(
100
,
nogil
=
True
):
if
i
+
j
>
60
:
with
gil
:
raise
Exception
(
"try and catch me if you can!"
)
except
Exception
,
e
:
exceptions
.
append
(
e
)
break
print
len
(
exceptions
)
==
num_threads
assert
len
(
exceptions
)
==
num_threads
,
(
len
(
exceptions
),
num_threads
)
OPENMP_PARALLEL
=
True
include
"sequential_parallel.pyx"
tests/run/sequential_parallel.pyx
View file @
3ddd9709
...
...
@@ -403,6 +403,84 @@ def test_parallel_exceptions():
print
mylist
[
0
]
print
e
.
args
,
sum
cdef
int
parallel_exc_cdef
()
except
-
3
:
cdef
int
i
,
j
for
i
in
prange
(
10
,
nogil
=
True
):
for
j
in
prange
(
10
,
num_threads
=
6
):
with
gil
:
raise
Exception
(
"propagate me"
)
return
0
def
test_parallel_exc_cdef
():
"""
>>> test_parallel_exc_cdef()
Traceback (most recent call last):
...
Exception: propagate me
"""
parallel_exc_cdef
()
cpdef
int
parallel_exc_cpdef
()
except
-
3
:
cdef
int
i
,
j
for
i
in
prange
(
10
,
nogil
=
True
):
for
j
in
prange
(
10
,
num_threads
=
6
):
with
gil
:
raise
Exception
(
"propagate me"
)
return
0
def
test_parallel_exc_cpdef
():
"""
>>> test_parallel_exc_cpdef()
Traceback (most recent call last):
...
Exception: propagate me
"""
parallel_exc_cpdef
()
cdef
int
parallel_exc_nogil_swallow
()
except
-
1
:
cdef
int
i
,
j
for
i
in
prange
(
10
,
nogil
=
True
):
try
:
for
j
in
prange
(
10
):
with
gil
:
raise
Exception
(
"propagate me"
)
finally
:
return
i
return
0
def
test_parallel_exc_nogil_swallow
():
"""
>>> test_parallel_exc_nogil_swallow()
execute me
"""
parallel_exc_nogil_swallow
()
print
'execute me'
def
parallel_exc_replace
():
"""
>>> parallel_exc_replace()
Traceback (most recent call last):
...
Exception: propagate me instead
"""
cdef
int
i
,
j
for
i
in
prange
(
10
,
nogil
=
True
):
with
gil
:
try
:
for
j
in
prange
(
10
,
nogil
=
True
):
with
gil
:
raise
Exception
(
"propagate me"
)
except
Exception
,
e
:
raise
Exception
(
"propagate me instead"
)
return
0
def
_parallel_exceptions2
():
cdef
int
i
,
j
,
k
...
...
@@ -423,6 +501,7 @@ def test_parallel_exceptions2():
test_parallel_exceptions2()
read: start
propagate me
exiting...
Exit status: 0
"""
if
not
hasattr
(
os
,
'fork'
):
...
...
@@ -454,6 +533,7 @@ def test_parallel_exceptions2():
import
traceback
print
>>
fw
,
traceback
.
format_exc
()
finally
:
print
>>
fw
,
'exiting...'
os
.
_exit
(
0
)
else
:
fw
.
close
()
...
...
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