Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.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.064 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'postgresql,': 0.09; 'cc:addr:python-list': 0.11; 'thread': 0.14; '(it': 0.16; 'blocked': 0.16; 'deletion': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'thread,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'seems': 0.21; 'issue.': 0.22; 'saying': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'entries': 0.24; 'script.': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'easier': 0.31; 'that.': 0.31; 'usually': 0.31; 'end,': 0.31; 'larry': 0.31; 'probably': 0.32; 'fri,': 0.33; 'guess': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'disk': 0.36; 'server': 0.38; 'connections': 0.38; 'issue': 0.38; 'most': 0.60; 'tell': 0.60; 'eye': 0.61; 'monitoring': 0.61; "you're": 0.61; 'more': 0.64; 'connection.': 0.74; 'jul': 0.74; 'special': 0.74; "it'd": 0.84; 'join.': 0.91; 'to:none': 0.92; 'reliable,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=N06haPrWWUw8+zbzaJbBNJCxU0D621YIpW63aEQbkz8=; b=bscV32626j1IuatlRKck8HhUw7YeFCNfR/STrg/J9l18kxH8iff8IDf2uwhnuaOTGk Mz6h3GRWgD0yZzbR84vA4gu5rcL+3MCxu7qCaDauVqIrnUbZ7EOciZUIoDorPZvZYX3M sftluyvBjkn6ffOxCHaUlvQYpPUlc3n5r1J4h6u9AxYicxbaRF3/Vkn06rISiUgqSlRl LMSZLbmL3JjC+aGci3EhKe/hSgHmMxlfv2eIQ1aIV9R37t3AHNYDjcvtrLEnEM0Hcubt EPvbPsieeUzfVvP0jUAESOvK2J8h4Xb7Asf/yqcT5K6iHRqRCz8qmH46rmUG1lw4bRK4 qTbQ== MIME-Version: 1.0 X-Received: by 10.52.178.66 with SMTP id cw2mr6320126vdc.93.1405620073875; Thu, 17 Jul 2014 11:01:13 -0700 (PDT) In-Reply-To: References: Date: Fri, 18 Jul 2014 04:01:13 +1000 Subject: Re: Blocked thread From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405620077 news.xs4all.nl 2914 [2001:888:2000:d::a6]:54482 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74656 On Fri, Jul 18, 2014 at 3:55 AM, Larry Martell wrote: > I can have as many connections to the db server as I want, that's not > the issue. The issue is that my main thread seems to be blocked in the > join(), so I guess I'm going to need a separate script. I was trying > to avoid that. Right, but what you're trying to do is monitor the local thread, by spinning off a thread to do the deletion and then keeping an eye on it by attempting a timed join. I'm saying it'd probably be easier to do the monitoring on the server end, via a second connection. (It most likely doesn't need special database privileges, even; at least in PostgreSQL, any user can see pg_stat_activity entries for the same user.) That's usually going to be more reliable, plus the server can tell you whether the deletion is blocked waiting for a lock or busy writing to the disk or something else. ChrisA