Created
May 29, 2016 10:36
-
-
Save roolebo/3bad473c89ff6d133ea37228bc79c5db to your computer and use it in GitHub Desktop.
Python 3.4-3.5 pipe leak in multiprocessing.Process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from multiprocessing import Process | |
import time | |
import os | |
import fcntl | |
def count_leaks(process_count): | |
def p_start(i): | |
print(i) | |
procs = [] | |
for i in range(process_count): | |
p = Process(target=p_start, args=(str(i),)) | |
p.start() | |
procs.append(p) | |
for p in procs: | |
p.join() | |
leaks = 0 | |
for p in procs: | |
try: | |
fcntl.fcntl(p.sentinel, fcntl.F_GETFD) | |
except: | |
pass | |
else: | |
os.close(p.sentinel) | |
leaks += 1 | |
return leaks | |
class MpPipeLeakTest(unittest.TestCase): | |
def test(self): | |
self.assertEqual(count_leaks(10), 0) | |
if __name__ == '__main__': | |
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
___________________________________ summary ____________________________________ | |
py26: commands succeeded | |
py27: commands succeeded | |
ERROR: py34: commands failed | |
ERROR: py35: commands failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tox] | |
envlist = py26, py27, py34, py35 | |
skipsdist=True | |
[testenv] | |
commands = python leak.py {posargs} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment