def set_runtime_options(options, Xparam, *args): if Xparam == 'track-resources': sys.pypy_set_track_resources(True) elif Xparam == 'faulthandler': run_faulthandler() else: print >> sys.stderr, 'usage: %s -X [options]' % (get_sys_executable(),) print >> sys.stderr, '[options] can be: track-resources, faulthandler' raise SystemExit
def set_runtime_options(options, Xparam, *args): if Xparam == 'track-resources': sys.pypy_set_track_resources(True) elif Xparam == 'faulthandler': run_faulthandler() else: print >> sys.stderr, 'usage: %s -X [options]' % ( get_sys_executable(), ) print >> sys.stderr, '[options] can be: track-resources, faulthandler' raise SystemExit
def test_track_resources_dont_crash(self): import os, gc, sys, cStringIO if '__pypy__' not in sys.builtin_module_names: skip("pypy specific test") # # try hard to create a code object whose co_filename points to an # EXISTING file, so that traceback.py tries to open it when formatting # the stacktrace f = open(self.temppath, 'w') f.close() co = compile('open(r"%s")' % self.temppath, self.temppath, 'exec') sys.pypy_set_track_resources(True) try: # this exec used to fail, because space.format_traceback tried to # recurively open a file, causing an infinite recursion. For the # purpose of this test, it is enough that it actually finishes # without errors exec co finally: sys.pypy_set_track_resources(False)
def fn(flag1, flag2, do_close=False): sys.pypy_set_track_resources(flag1) mysock = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM, 0) sys.pypy_set_track_resources(flag2) buf = cStringIO.StringIO() preverr = sys.stderr try: sys.stderr = buf if do_close: mysock.close() del mysock gc.collect() # force __del__ to be called finally: sys.stderr = preverr sys.pypy_set_track_resources(False) return buf.getvalue()
def fn(flag1, flag2, do_close=False): sys.pypy_set_track_resources(flag1) f = self.file(self.temppath, 'w') sys.pypy_set_track_resources(flag2) buf = cStringIO.StringIO() preverr = sys.stderr try: sys.stderr = buf if do_close: f.close() del f gc.collect() # force __del__ to be called finally: sys.stderr = preverr sys.pypy_set_track_resources(False) return buf.getvalue()