File: lock_type.pyx

package info (click to toggle)
cython 3.1.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,932 kB
  • sloc: python: 92,172; ansic: 19,275; cpp: 1,407; xml: 1,031; javascript: 511; makefile: 373; sh: 223; sed: 11
file content (34 lines) | stat: -rw-r--r-- 818 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# mode: error

cimport cython

cdef takes_a_lock(cython.pymutex l):
    pass

cdef cython.pymutex uncopyable():
    cdef cython.pymutex l
    cdef object o
    takes_a_lock(l)
    l2 = l
    o = l
    return l

def no_yield():
    cdef cython.pymutex l
    with l:
        yield  # banned due to very high possibility of deadlock


cdef void misuse_the_gil() noexcept nogil:
    cdef cython.pymutex l
    with l:
        with gil:
            pass

_ERRORS = """
11:17: cython.pymutex cannot be copied
12:9: cython.pymutex cannot be copied
13:8: Cannot convert 'cython.pymutex' to Python object
14:11: cython.pymutex cannot be copied
18:9: Cannot use a 'with' statement with a 'cython.pymutex' in a generator. If you really want to do this (and you are confident that there are no deadlocks) then use try-finally.
"""