Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.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.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'globally.': 0.07; 'suppose': 0.07; 'wrapper': 0.07; 'subject:question': 0.08; 'mess': 0.09; 'sockets': 0.09; 'yeah,': 0.09; 'thread': 0.11; "wouldn't": 0.11; 'mapping,': 0.16; 'poll': 0.16; 'passes': 0.17; 'sender:addr:gmail.com': 0.18; 'paul': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'rest': 0.28; 'chris': 0.28; 'wrap': 0.29; 'writes:': 0.29; 'probably': 0.29; 'class': 0.29; "i'm": 0.29; 'could': 0.32; 'to:addr:python-list': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'mapping': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'created': 0.36; 'but': 0.36; "wasn't": 0.36; 'anything': 0.36; 'too': 0.36; 'rather': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'planning': 0.38; 'to:addr:python.org': 0.39; 'application': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'you.': 0.61; 'places': 0.61; 'tracking': 0.61; 'different': 0.63; 'more': 0.63; 'news': 0.68; 'received:117': 0.75; 'message-id:@mx.google.com': 0.81; 'manages': 0.84; 'careful': 0.91; 'dealt': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:subject:in-reply-to:references:user-agent :date:message-id:mime-version:content-type; bh=wpg1oJ6l4Tp07Eek31ieeUjCqppOIRG+kjZV6mIoumY=; b=V0OAGQJEEh1Iep408dYIYUEsEh1R+vFiqGEjpRnVz1lzYmeOl/2nr6hNfjpxJTLGZ/ MO7Kd5vqE84igit9yHbEkt0zqTNSFfclLYJDzJEZVEIhU1WSgSk54yDTKloaf610HnS/ 17wSKHPZNPWuhX56WkBlJ74BeI8i2RFFjScmO/xk72zfL0DtST7QUmSdY6hN9gxLHnZF j2CFKYoK6tvNZKEWH+GuTU9T0/JGqv8dHpiCZ1B5JyHPbfRvhm2h5D8TrUqdyPpY78fS bg0D+WCw8jTMK7KkzwCRvr57Cai13d22aaoOWbGQG4mCMfSn5A6/bZjfcPX3wuMoCe6x 9AhQ== X-Received: by 10.66.79.195 with SMTP id l3mr11566014pax.82.1360289221801; Thu, 07 Feb 2013 18:07:01 -0800 (PST) Sender: Kushal Kumaran From: Kushal Kumaran To: python-list@python.org Subject: Re: select.epoll question In-Reply-To: <7xliazq3ky.fsf@ruckus.brouhaha.com> References: <7xbobw1tzr.fsf@ruckus.brouhaha.com> <7x1ucs2j8m.fsf@ruckus.brouhaha.com> <7xliazq3ky.fsf@ruckus.brouhaha.com> User-Agent: Notmuch/0.15+12~gd5a2352 (http://notmuchmail.org) Emacs/24.1.1 (x86_64-pc-linux-gnu) Date: Fri, 08 Feb 2013 07:36:52 +0530 MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360289225 news.xs4all.nl 6894 [2001:888:2000:d::a6]:50921 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38392 Paul Rubin writes: > Chris Angelico writes: >> Yeah, I figured fileno() probably wouldn't be news to you. I don't >> suppose there's anything convenient in the rest of your application >> that makes such a list/dict plausible? > > In fact it's rather annoying, sockets are created and destroyed in > multiple places in the program. I have to be careful about leaking them > in case a thread crashes, etc. I dealt with the poll issue by manually > tracking what was happening, but it wasn't pretty, so I wondered if > there was a better solution I was overlooking. I don't want to mess > with it too much more since I'm planning a completely different approach > for the next version of the program. You don't have to maintain the mapping globally. You could wrap socket.epoll in a class of your own that manages the mapping, and passes through calls to socket.epoll. That would make the wrapper a drop-in replacement for socket.epoll. -- regards, kushal