Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!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.038 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'agree,': 0.09; 'callback': 0.09; '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; 'script,': 0.16; 'thread,': 0.16; 'threads.': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'thu,': 0.19; 'seems': 0.21; '>>>': 0.22; 'issue.': 0.22; 'saying': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'entries': 0.24; 'script.': 0.24; 'simpler': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'query': 0.26; '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; 'gives': 0.31; 'easier': 0.31; 'that.': 0.31; 'usually': 0.31; 'end,': 0.31; 'larry': 0.31; 'probably': 0.32; 'another': 0.32; 'fri,': 0.33; 'guess': 0.33; 'could': 0.34; 'connection': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'disk': 0.36; 'oracle': 0.36; 'done': 0.36; 'doing': 0.36; 'possible': 0.36; 'two': 0.37; 'server': 0.38; 'connections': 0.38; 'issue': 0.38; 'pm,': 0.38; 'either': 0.39; 'most': 0.60; 'tell': 0.60; 'eye': 0.61; 'monitoring': 0.61; "you're": 0.61; 'first': 0.61; 'more': 0.64; 'facilities': 0.69; 'connection.': 0.74; 'jul': 0.74; 'special': 0.74; "it'd": 0.84; 'you;': 0.84; 'join.': 0.91; 'to:none': 0.92; '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:cc :content-type; bh=N5zXa5WvpGfydvJADIb3zIw/qNpi8e70JO7Eba5yYWA=; b=WCmChQfjp47g1RcifEul+HWjIimPIkdIK53VgWkJgnfltYH1r6KVJfin4WXfPZsTDg SJ5ybxpKzPCBcCTh+gzWmW8zoKJXoixOrsw2ELHirF3OsUu+8pH0OnjEAhLJjlwoVPXL NAoBnyRkrN2N2fs2P3jwD1CM8abAc1f+GvYuMJw6FRYqpIMOTmk0qgd0NVNH6kB5keMo iJsmLPR+DXMdVfdtTr67CPPAvLf+wCHOaPrIIGzZP1ABKxOFbhDA+HLkQWXk7X8YZmzK IpniCvuHVwSoD15yM8y7+WQ3cRRblYXLr5u0NT1qtSiv+busewdDEPJUyrK8dEBshnYS NJ6A== MIME-Version: 1.0 X-Received: by 10.220.164.198 with SMTP id f6mr20721286vcy.51.1405620573465; Thu, 17 Jul 2014 11:09:33 -0700 (PDT) In-Reply-To: References: Date: Fri, 18 Jul 2014 04:09:33 +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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405620575 news.xs4all.nl 2950 [2001:888:2000:d::a6]:36573 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74661 On Fri, Jul 18, 2014 at 4:03 AM, Larry Martell wrote: > 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. Maybe. I don't know what facilities Oracle gives you; it might be possible to start a query asynchronously, with either a callback when it's done or a poll for completion. Then another connection could be used to keep an eye on the first one. But yes, doing it with a completely separate script would be simpler in many ways. Or you might be able to do the job with two threads. ChrisA