Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'yet.': 0.05; 'subject:process': 0.09; 'closes': 0.16; 'doing:': 0.16; 'dynamically': 0.16; 'handler)': 0.16; 'port),': 0.16; 'subprocess': 0.16; 'terminated.': 0.16; 'files.': 0.18; 'handler': 0.18; 'trying': 0.20; 'http': 0.22; 'basically': 0.23; 'run': 0.26; 'server.': 0.27; 'needed.': 0.27; 'fails.': 0.29; 'setting': 0.30; "doesn't": 0.30; 'mostly': 0.30; 'script': 0.31; 'problem': 0.34; 'skip:s 30': 0.34; 'server': 0.34; 'skip:s 40': 0.35; 'there': 0.35; "i'm": 0.36; 'done': 0.36; 'hi!': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'port': 0.37; 'some': 0.37; 'common': 0.38; 'client': 0.38; 'received:org': 0.38; 'doing': 0.39; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'act': 0.60; 'better': 0.63; 'header:Message-Id:1': 0.65; 'serving': 0.67; 'received:130': 0.73 X-Virus-Scanned: amavisd-new at catalogix.se From: Roland Hedberg Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Slow termination of process Date: Tue, 27 Mar 2012 15:03:11 +0200 To: python-list@python.org Mime-Version: 1.0 (Apple Message framework v1257) X-Mailer: Apple Mail (2.1257) 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332855527 news.xs4all.nl 6966 [2001:888:2000:d::a6]:56827 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22243 Hi! I have an application/a script that is run from another application. The script is mostly working as a HTTP client but in some cases it also = has to act as a HTTP server. Basically just for serving a few files. The files are dynamically = created by the script when needed. To accomplish this I'm trying to use subprocess Popen and an extremely simple web server script which basically contains: Handler =3D SimpleHTTPServer.SimpleHTTPRequestHandler httpd =3D SocketServer.TCPServer((hostname, port), Handler) httpd.serve_forever() In the main script I do: op =3D Popen(popen_args, stdout=3DPIPE, stderr=3DPIPE) When the main script is done it closes down the HTTP server by doing: op.terminate() The problem I have is that if the main script is run again almost = immediate then the old HTTP server=20 process doesn't seem to have released the port yet. So setting up a new = server fails. Is there anything I can do to get the port released immediately when the = tcpserver is terminated. Or is there another way of doing this that will work better ? Roland ----------------------------------------------------------- With anchovies there is no common ground=20 -- Nero Wolfe