Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; '2.7': 0.04; 'bsd': 0.05; 'migrate': 0.07; 'python': 0.08; 'function:': 0.09; 'overwrite': 0.09; 'seriously.': 0.09; 'subject:files': 0.09; 'though:': 0.09; 'api': 0.09; 'to:name:python-list@python.org': 0.15; 'thanks!': 0.15; 'backported': 0.16; 'file).': 0.16; 'files"': 0.16; 'open()': 0.16; 'subclasses.': 0.16; 'twisted': 0.16; 'linux': 0.17; '>>>': 0.18; 'string,': 0.18; 'to:2**1': 0.19; 'compatible': 0.21; 'stuff': 0.22; 'breaks': 0.23; 'header :In-Reply-To:1': 0.23; 'there.': 0.24; 'code': 0.25; 'function': 0.27; 'import': 0.28; 'unicode': 0.28; 'print': 0.29; 'class': 0.29; 'seem': 0.30; 'subject:number': 0.30; 'thanks': 0.31; 'version': 0.31; 'go.': 0.32; 'yet': 0.32; 'app': 0.32; 'to:addr :python-list': 0.32; "i've": 0.33; 'there': 0.33; 'it?': 0.33; 'creates': 0.34; 'received:169': 0.34; 'received:169.254': 0.34; 'probably': 0.34; 'function.': 0.34; 'running': 0.35; 'subject:/': 0.35; 'problem.': 0.36; 'file': 0.36; '...': 0.36; 'uses': 0.36; 'charset:us-ascii': 0.36; 'checks': 0.36; 'another': 0.36; 'but': 0.37; 'using': 0.37; 'could': 0.38; 'patch': 0.38; 'open': 0.38; 'created': 0.38; 'skip:o 20': 0.38; 'option': 0.38; 'either': 0.39; "it's": 0.39; 'subject:: ': 0.39; 'might': 0.39; 'to:addr:python.org': 0.39; 'skip:_ 10': 0.40; 'getting': 0.40; 'files': 0.40; 'more': 0.60; 'your': 0.61; '1000': 0.62; 'opened': 0.64; 'non-unicode': 0.84; 'old,': 0.97 From: Tobias Oberstein To: Christian Heimes , "python-list@python.org" Date: Mon, 14 Nov 2011 10:28:21 -0800 Subject: AW: Py2.7/FreeBSD: maximum number of open files Thread-Topic: Py2.7/FreeBSD: maximum number of open files Thread-Index: Acyi+CoZB1UxKu8NRD2cb3wg1vTuiwAAmHTw References: <634914A010D0B943A035D226786325D42D0C264772@EXVMBX020-12.exch020.serverdata.net> <634914A010D0B943A035D226786325D42D0C2647C8@EXVMBX020-12.exch020.serverdata.net> <4EC1470B.90403@cheimes.de> <634914A010D0B943A035D226786325D42D0C26481A@EXVMBX020-12.exch020.serverdata.net> In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE, en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321295306 news.xs4all.nl 6905 [2001:888:2000:d::a6]:43435 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15686 > > I just confirmed that the bug is even there for FreeBSD 9 RC1 ! > > > > This is most unfortunate. Seriously. >=20 > W00t, that sucks! You could migrate to another BSD (NetBSD) or Linux ... = :) No, thanks;) > > I am running out of options, since I am willing to make my stuff > > Python 3 compatible, but Twisted is not yet there. > > > > Using the backported new IO on Python 2.7 will not make open() > automatically use the new IO, will it? >=20 > No, the open() function of Python 2.7 will still use the file class which= in > return uses fopen(). You could try to monkey patch the built-in > open() function. It's mostly API compatible with the current open() > function: >=20 > >>> import io, __builtin__ > >>> __builtin__.open =3D io.open >=20 > It works as long as no codes checks for isinstance(obj, file). If your ap= p only > has to worry about log files, you might want to overwrite the > _open() method of logging.FileHandler and its subclasses. >=20 Thanks! This is probably the most practical option I can go. I've just tested: the backported new IO on Python 2.7 will indeed open >32k files on FreeBSD. It also creates the files much faster. The old, non-monkey-patched version was getting slower and slower as more files were opened/created .. There seem to be slight differences though: Non-monkey patched: I can write to the file a non-Unicode string, even when the file was opened non-Binary. With monkey patch: either open the file Binary-mode, or write Unicode strings .. I need to see if / what breaks in Twisted. I can handle my own code .. no problem. Thanks alot!! import io, __builtin__ __builtin__.open =3D io.open import resource max =3D resource.getrlimit(resource.RLIMIT_NOFILE) cnt =3D 0 print "maximum FDs", max max =3D 33000 fds =3D [] while cnt < max: f =3D open("/tmp/test1/test_%d" % cnt, "wb") f.write("test") fds.append(f) cnt +=3D 1 if cnt % 1000 =3D=3D 0: print "opened %d files" % cnt print "ok, created %d files" % cnt