fixed cron deadlock on windows, thanks Helko Besemann

This commit is contained in:
Massimo
2013-09-03 11:53:18 -05:00
parent fd000fe35b
commit e724e13564
4 changed files with 74 additions and 23 deletions
+9 -5
View File
@@ -48,12 +48,12 @@ _DEBUG = True
_HISTORY_KIND = '_Shell_History'
# Types that can't be pickled.
UNPICKLABLE_TYPES = (
UNPICKLABLE_TYPES = [
types.ModuleType,
types.TypeType,
types.ClassType,
types.FunctionType,
)
]
# Unpicklable statements to seed new historys with.
INITIAL_UNPICKLABLES = [
@@ -244,8 +244,8 @@ def run(history, statement, env={}):
for name, val in statement_module.__dict__.items():
if name not in old_globals or represent(val) != old_globals[name]:
new_globals[name] = val
if True in [isinstance(val, UNPICKLABLE_TYPES)
if True in [isinstance(val, tuple(UNPICKLABLE_TYPES))
for val in new_globals.values()]:
# this statement added an unpicklable global. store the statement and
# the names of all of the globals it added in the unpicklables.
@@ -256,7 +256,11 @@ def run(history, statement, env={}):
# new globals back into the datastore.
for name, val in new_globals.items():
if not name.startswith('__'):
history.set_global(name, val)
try:
history.set_global(name, val)
except TypeError, ex:
UNPICKLABLE_TYPES.append(type(val))
history.add_unpicklable(statement, new_globals.keys())
finally:
sys.modules['__main__'] = old_main