diff 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
line wrap: on
line diff
--- a/compat.py	Mon Jan 17 11:11:01 2011 +0000
+++ b/compat.py	Wed Feb 16 00:01:33 2011 +0000
@@ -44,7 +44,7 @@
 	import __builtin__ as builtins
 
 pseudobuiltins = ('say', 'basestring', 'range', 'map', 'zip', 'filter', 'next',
-                  'items', 'keys', 'values', 'zip_longest', 'callable')
+                  'items', 'keys', 'values', 'zip_longest', 'callable', 'ceil')
 __all__ = pseudobuiltins + ('ABCMeta', 'abstractmethod', 'CompatBuiltins')
 
 try:
@@ -198,6 +198,13 @@
 except AttributeError:
 	values = dict.values
 
+from math import ceil
+if not isinstance(ceil(0), int):
+	def ceil(x):
+		y = int(x)
+		if y < x: y += 1
+		return y
+
 try:
 	# Python 3
 	from itertools import zip_longest