Commit 1f394dc7 authored by Julien Muchembled's avatar Julien Muchembled

Fix TypeError when the system lacks memory

This fixes up commit e3781aff
(Reduce probability of dying when the system lacks memory").
parent 87bc6bb9
...@@ -148,20 +148,21 @@ exit = exit() ...@@ -148,20 +148,21 @@ exit = exit()
class Popen(subprocess.Popen): class Popen(subprocess.Popen):
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
try: try:
super(Popen, self).__init__(*args, **kw) super(Popen, self).__init__(*args, **kw)
except OSError, e: except OSError, e:
if e.errno != errno.ENOMEM: if e.errno != errno.ENOMEM:
raise raise
self.returncode = -1 self.returncode = -1
def stop(self): def stop(self):
self.terminate() if self.pid:
t = threading.Timer(5, self.kill) self.terminate()
t.start() t = threading.Timer(5, self.kill)
r = self.wait() t.start()
t.cancel() r = self.wait()
return r t.cancel()
return r
def makedirs(path): def makedirs(path):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment