Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.069 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'agree,': 0.09; 'postgresql,': 0.09; 'thread': 0.14; '(it': 0.16; 'blocked': 0.16; 'deletion': 0.16; 'script,': 0.16; 'thread,': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'seems': 0.21; 'issue.': 0.22; 'saying': 0.22; 'separate': 0.22; 'to:name:python- list@python.org': 0.22; 'entries': 0.24; 'script.': 0.24; 'script': 0.25; 'second': 0.26; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; '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; 'connection': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'disk': 0.36; 'server': 0.38; 'connections': 0.38; 'to:addr :python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; '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; 'have.': 0.93; '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:to :content-type; bh=oZYgSQPBezjGvpKxhSANQy7C3CpYEzH1lpR3i9OxHAU=; b=G98hXvWNbdtQUScmhiEcbAz8JfoJlMiETgftHvU4S0SVFHTUwdWK+doJQAt3KwQlkS lR8yr88SZBIqCTsRewumMn1DnzqX4oggaHOX9KjpHJyHujvKmWz14l49LXLKPSfGM0WS NEGLhsugqcp8zoCKgGPu/OEjJ6yKJabTjbjL6Qqb9hg8Fiw5cijsKB0SXqEUPn6VIHOQ tS8utsT0kX6uAXEgf98rUenBKI8fhfERLGukNe6ydeY+7MjIloB7GyUbxtZOr9ODNHl8 hYfeYqhzSOnP33Povv1T9GUGg52S+yCNEC6MFPZdxnmk+2U4wqEd6tR2/BLLHbqU5Th2 ISAw== MIME-Version: 1.0 X-Received: by 10.180.82.166 with SMTP id j6mr24047149wiy.71.1405620206352; Thu, 17 Jul 2014 11:03:26 -0700 (PDT) In-Reply-To: References: Date: Thu, 17 Jul 2014 14:03:26 -0400 Subject: Re: Blocked thread From: Larry Martell To: "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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405620209 news.xs4all.nl 2961 [2001:888:2000:d::a6]:58433 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74658 On Thu, Jul 17, 2014 at 2:01 PM, Chris Angelico wrote: > 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. Yes, I agree, but the second connection will have to be in a second script, not the main thread of the script I have.