def test_read_from_env(): saved = os.environ try: os.environ = FakeEnviron(None) check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('???') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1') check_equal(env.read_from_env('FOOBAR'), 1) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1)) check_equal(env.read_float_from_env('FOOBAR'), 1.0) # os.environ = FakeEnviron('12345678') check_equal(env.read_from_env('FOOBAR'), 12345678) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(12345678)) check_equal(env.read_float_from_env('FOOBAR'), 12345678.0) # os.environ = FakeEnviron('1234B') check_equal(env.read_from_env('FOOBAR'), 1234) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1234)) check_equal(env.read_float_from_env('FOOBAR'), 1234.0) # os.environ = FakeEnviron('1.5') check_equal(env.read_float_from_env('FOOBAR'), 1.5) # os.environ = FakeEnviron('1.5Kb') check_equal(env.read_from_env('FOOBAR'), 1536) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1536)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5mB') check_equal(env.read_from_env('FOOBAR'), int(1.5 * 1024 * 1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5 * 1024 * 1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5g') check_equal(env.read_from_env('FOOBAR'), int(1.5 * 1024 * 1024 * 1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5 * 1024 * 1024 * 1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # finally: os.environ = saved
def test_read_from_env(): saved = os.environ try: os.environ = FakeEnviron(None) check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('???') check_equal(env.read_from_env('FOOBAR'), 0) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(0)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1') check_equal(env.read_from_env('FOOBAR'), 1) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1)) check_equal(env.read_float_from_env('FOOBAR'), 1.0) # os.environ = FakeEnviron('12345678') check_equal(env.read_from_env('FOOBAR'), 12345678) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(12345678)) check_equal(env.read_float_from_env('FOOBAR'), 12345678.0) # os.environ = FakeEnviron('1234B') check_equal(env.read_from_env('FOOBAR'), 1234) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1234)) check_equal(env.read_float_from_env('FOOBAR'), 1234.0) # os.environ = FakeEnviron('1.5') check_equal(env.read_float_from_env('FOOBAR'), 1.5) # os.environ = FakeEnviron('1.5Kb') check_equal(env.read_from_env('FOOBAR'), 1536) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1536)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5mB') check_equal(env.read_from_env('FOOBAR'), int(1.5*1024*1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5*1024*1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # os.environ = FakeEnviron('1.5g') check_equal(env.read_from_env('FOOBAR'), int(1.5*1024*1024*1024)) check_equal(env.read_uint_from_env('FOOBAR'), r_uint(1.5*1024*1024*1024)) check_equal(env.read_float_from_env('FOOBAR'), 0.0) # finally: os.environ = saved
def setup(self): envsize = env.read_from_env("PYPY_MARKCOMPACTGC_MAX") if envsize >= 4096: self.space_size = envsize & ~4095 mincollect = env.read_from_env("PYPY_MARKCOMPACTGC_MIN") if mincollect >= 4096: self.min_next_collect_after = mincollect # self.program_start_time = time.time() self.space = llarena.arena_malloc(self.space_size, False) if not self.space: raise CannotAllocateGCArena self.free = self.space MovingGCBase.setup(self) self.objects_with_finalizers = self.AddressDeque() self.tid_backup = lltype.nullptr(TID_BACKUP) self.next_collect_after = self.next_collection(0, 0, 0)
def setup(self): envsize = env.read_from_env('PYPY_MARKCOMPACTGC_MAX') if envsize >= 4096: self.space_size = envsize & ~4095 mincollect = env.read_from_env('PYPY_MARKCOMPACTGC_MIN') if mincollect >= 4096: self.min_next_collect_after = mincollect #self.program_start_time = time.time() self.space = llarena.arena_malloc(self.space_size, False) if not self.space: raise CannotAllocateGCArena self.free = self.space MovingGCBase.setup(self) self.objects_with_finalizers = self.AddressDeque() self.tid_backup = lltype.nullptr(TID_BACKUP) self.next_collect_after = self.next_collection(0, 0, 0)
def nursery_size_from_env(): return env.read_from_env('PYPY_GENERATIONGC_NURSERY')
def post_setup(self): # More stuff that needs to be initialized when the GC is already # fully working. (Only called by gctransform/framework for now.) from pypy.rpython.memory.gc import env self.DEBUG = env.read_from_env('PYPY_GC_DEBUG')