rlib/test/test_rgil.py::TestGILShadowStack::()::test_am_I_holding_the_GIL
self = <rpython.rlib.test.test_rgil.TestGILShadowStack object at 0x00000293cf82e480>
def test_am_I_holding_the_GIL(self):
def check(name, expected=True):
# we may not have the GIL here, don't use "print"
debug_print(name)
if rgil.am_I_holding_the_GIL() != expected:
debug_print('assert failed at point', name)
debug_print('rgil.gil_get_holder() ==', rgil.gil_get_holder())
assert False
def main(argv):
check('1')
rgil.release()
# don't have the GIL here
check('2', False)
rgil.acquire()
check('3')
rgil.yield_thread()
check('4')
print "OK" # there is also a release/acquire pair here
check('5')
return 0
main([])
t, cbuilder = self.compile(main)
> data = cbuilder.cmdexec('')
rlib\test\test_rgil.py:67:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.translator.c.genc.CStandaloneBuilder object at 0x00000293cd4b3e88>
args = '', env = None, err = False, expect_crash = False
exe = local('d:\\systemtemp\\pytest\\usession-main-1418\\testing_3\\testing_3.exe')
def cmdexec(self, args='', env=None, err=False, expect_crash=False, exe=None):
assert self._compiled
if sys.platform == 'win32':
#Prevent opening a dialog box
import ctypes
winapi = ctypes.windll.kernel32
SetErrorMode = winapi.SetErrorMode
SetErrorMode.argtypes=[ctypes.c_int]
SEM_FAILCRITICALERRORS = 1
SEM_NOGPFAULTERRORBOX = 2
SEM_NOOPENFILEERRORBOX = 0x8000
flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX \
| SEM_NOOPENFILEERRORBOX
#Since there is no GetErrorMode, do a double Set
old_mode = SetErrorMode(flags)
SetErrorMode(old_mode | flags)
if env is None:
envrepr = ''
else:
envrepr = ' [env=%r]' % (env,)
env.update(os.environ)
if exe is None:
exe = self.executable_name
log.cmdexec('%s %s%s' % (exe, args, envrepr))
res = self.translator.platform.execute(exe, args, env=env)
if sys.platform == 'win32':
SetErrorMode(old_mode)
if res.returncode != 0:
if expect_crash:
if type(expect_crash) is int and expect_crash != res.returncode:
raise Exception("Returned %d, but expected %d" % (
res.returncode, expect_crash))
return res.out, res.err
print(res.err, file=sys.stderr)
> raise Exception("Returned %d" % (res.returncode,))
E Exception: Returned 3221225477
translator\c\genc.py:318: Exception
---------- Captured stdout call ----------
OK
---------- Captured stderr call ----------
1
2
3
4
5
[platform:msg] Updated environment with vsver 160, using x64 True
[rtyper] specializing: 100 / 327 blocks (30%)
[rtyper] specializing: 200 / 386 blocks (51%)
[rtyper] specializing: 300 / 386 blocks (77%)
[rtyper] -=- specialized 386 blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] specializing: 400 / 415 blocks (96%)
[rtyper] -=- specialized 25 more blocks -=-
[rtyper] -=- specialized 60 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 6 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] specializing: 500 / 553 blocks (90%)
[rtyper] -=- specialized 78 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[rtyper] -=- specialized 30 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 1 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[backendopt:malloc] removed 0 simple mallocs in total
[c:database] GC transformer: finished helpers
[c:database] GC transformer: finished tables
[c:database] Inlining GC helpers and postprocessing
[c] 396 nodes [ array: 29 func: 162 refcnt rtti: 18 struct: 187 ]
[c:database] Completed
[c:writing] structdef.h
[c:writing] forwarddecl.h
[c:writing] preimpl.h
[c:writing] data_rpython_flowspace.c
[c:writing] data_rpython_memory_gctransform.c
[c:writing] data_rpython_rlib.c
[c:writing] data_rpython_rlib_test.c
[c:writing] data_rpython_rtyper.c
[c:writing] data_rpython_rtyper_lltypesystem.c
[c:writing] data_rpython_translator_c.c
[c:writing] nonfuncnodes.c
[c:writing] data_rpython_rlib_1.c
[c:writing] implement.c
[c:writing] rpython_flowspace.c
[c:writing] rpython_memory_gctransform.c
[c:writing] rpython_rlib.c
[c:writing] rpython_rlib_test.c
[c:writing] rpython_rtyper.c
[c:writing] rpython_rtyper_lltypesystem.c
[c:writing] rpython_translator.c
[c:writing] rpython_translator_c.c
[platform:execute] jom.exe in d:\systemtemp\pytest\usession-main-1418\testing_3
[c:cmdexec] d:\systemtemp\pytest\usession-main-1418\testing_3\testing_3.exe
builder: rpython-win-x86-64 build #400
test: rlib/test/test_rgil/py/TestGILShadowStack/()/test_am_I_holding_the_GIL