comparison compat.py @ 80:809b77302b21

Win32-specific module with memory and CPU time limits The Win32-specific implementation of call() and friends now lives in module win32, looks clean and in addition is able to enforce memory and CPU time limits on NT kernels, in particular on Windows 2000 and up asking the system to terminate the process as soon as or (in the case of CPU time) almost as soon as the limits are broken. According to my observations, malloc() in the limited process does not return NULL when memory usage is close to the limit and instead crashes the process (which Upreckon happily translates into 'memory limit exceeded'). The catch is that the module is not actually used yet; coming soon.
author Oleg Oshmyan <chortos@inbox.lv>
date Wed, 16 Feb 2011 00:01:33 +0000
parents d46bd7ee3e69
children cd347cfca272
comparison
equal deleted inserted replaced
79:ee8a99dcaaed 80:809b77302b21
42 import builtins 42 import builtins
43 except ImportError: 43 except ImportError:
44 import __builtin__ as builtins 44 import __builtin__ as builtins
45 45
46 pseudobuiltins = ('say', 'basestring', 'range', 'map', 'zip', 'filter', 'next', 46 pseudobuiltins = ('say', 'basestring', 'range', 'map', 'zip', 'filter', 'next',
47 'items', 'keys', 'values', 'zip_longest', 'callable') 47 'items', 'keys', 'values', 'zip_longest', 'callable', 'ceil')
48 __all__ = pseudobuiltins + ('ABCMeta', 'abstractmethod', 'CompatBuiltins') 48 __all__ = pseudobuiltins + ('ABCMeta', 'abstractmethod', 'CompatBuiltins')
49 49
50 try: 50 try:
51 # Python 3 51 # Python 3
52 exec('say = print') 52 exec('say = print')
196 try: 196 try:
197 values = dict.itervalues 197 values = dict.itervalues
198 except AttributeError: 198 except AttributeError:
199 values = dict.values 199 values = dict.values
200 200
201 from math import ceil
202 if not isinstance(ceil(0), int):
203 def ceil(x):
204 y = int(x)
205 if y < x: y += 1
206 return y
207
201 try: 208 try:
202 # Python 3 209 # Python 3
203 from itertools import zip_longest 210 from itertools import zip_longest
204 except ImportError: 211 except ImportError:
205 try: 212 try: