예제 #1
0
파일: app_main.py 프로젝트: mozillazg/pypy
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
예제 #2
0
파일: app_main.py 프로젝트: sota/pypy
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
예제 #3
0
파일: test_file.py 프로젝트: mozillazg/pypy
 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)
예제 #4
0
파일: test_file.py 프로젝트: Mu-L/pypy
 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)
예제 #5
0
 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()
예제 #6
0
 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()
예제 #7
0
파일: test_file.py 프로젝트: mozillazg/pypy
 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()
예제 #8
0
파일: test_file.py 프로젝트: Mu-L/pypy
 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()