Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'linux,': 0.05; 'socket': 0.05; 'python': 0.09; 'closed.': 0.09; 'sockets': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'cleanly': 0.16; 'subject:threads': 0.16; 'threaded': 0.16; 'wrote:': 0.17; 'wednesday,': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'script': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'received:209.85.212': 0.28; 'thus,': 0.29; 'writes:': 0.29; 'seconds': 0.30; 'monitor': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'alone': 0.36; 'closing': 0.36; 'should': 0.36; 'operating': 0.36; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'takes': 0.39; 'close': 0.63; 'subject:,': 0.81; 'dies.': 0.84; 'ports.': 0.84; 'killed': 0.91; 'received:209.85.212.56': 0.91 Newsgroups: comp.lang.python Date: Wed, 5 Sep 2012 05:54:41 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=122.167.254.242; posting-account=uPFZNQoAAAAm9w7z13q1SjWNKNjztdcD References: <4d1ffb61-38b6-42fb-9426-c1c7cb7038a0@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 122.167.254.242 MIME-Version: 1.0 Subject: Re: sockets,threads and interupts From: Ramchandra Apte To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: , Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346849685 news.xs4all.nl 6877 [2001:888:2000:d::a6]:41202 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28485 On Wednesday, 5 September 2012 11:26:16 UTC+5:30, Dieter Maurer wrote: > loial writes: > > > > > I have threaded python script that uses sockets to monitor network ports. > > > > > > I want to ensure that the socket is closed cleanly in all circumstances. This includes if the script is killed or interupted in some other way. > > > > The operating system should close all sockets automatically when > > the process dies. Thus, if closing alone is sufficient... At least on Linux, if you kill a process using sockets, it takes about 10 seconds for socket to be closed. A program should try to close all resources. OS'es may take a long time to close a unclosed socket automatically.