Commit b9f7a142 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2391 from gabrieldemarmiesse/test_parallelism_2

Added tests to "Using Parallelism" part 2
parents 241b8677 a6ee14bb
from cython.parallel import prange
cdef int func(Py_ssize_t n):
cdef Py_ssize_t i
for i in prange(n, nogil=True):
if i == 8:
with gil:
raise Exception()
elif i == 4:
break
elif i == 2:
return i
...@@ -191,21 +191,9 @@ exiting procedure is best-effort. For prange() this means that the loop ...@@ -191,21 +191,9 @@ exiting procedure is best-effort. For prange() this means that the loop
body is skipped after the first break, return or exception for any subsequent body is skipped after the first break, return or exception for any subsequent
iteration in any thread. It is undefined which value shall be returned if iteration in any thread. It is undefined which value shall be returned if
multiple different values may be returned, as the iterations are in no multiple different values may be returned, as the iterations are in no
particular order:: particular order:
from cython.parallel import prange .. literalinclude:: ../../examples/userguide/parallelism/breaking_loop.pyx
cdef int func(Py_ssize_t n):
cdef Py_ssize_t i
for i in prange(n, nogil=True):
if i == 8:
with gil:
raise Exception()
elif i == 4:
break
elif i == 2:
return i
In the example above it is undefined whether an exception shall be raised, In the example above it is undefined whether an exception shall be raised,
whether it will simply break or whether it will return 2. whether it will simply break or whether it will return 2.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment