Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'agree,': 0.09; 'callback': 0.09; 'postgres': 0.09; 'postgresql,': 0.09; 'cc:addr:python- list': 0.11; 'thread': 0.14; '(it': 0.16; 'blocked': 0.16; 'deletion': 0.16; 'non-blocking': 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; '>>>>': 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; 'in.': 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; 'to:addr:gmail.com': 0.65; 'facilities': 0.69; 'connection.': 0.74; 'jul': 0.74; 'special': 0.74; "it'd": 0.84; 'you;': 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 :cc:content-type; bh=W+zvstO+ZKC98LF6PyZyFkhoEA/q4ALAZjhwVL6bxTs=; b=dpd6Nmy1x5k3+JC28D2zrZaL63eIYMRLbmkHiGMPNIdzZbFtJhMHMsQy1ECoSFWi3Z h6QNhLbLy4FMGNOvoG2c7yDiVP0A7TauBReOsSN2xGzH0yVlnrwJtsA2TaZMQFbq1b9e 6cWEbIC0vavtFyMcUI6rL5mRNBzp9VEWl2LhKhk1hLe1+yNBOkVMPdAruNa805GEUVvm 6BSpbqEFnZCj+MvkQITXywNVCwtCFvWvTyR3YH3+1GG8qyENr79Yb1nql3GxNky5baGX G5i9Y/LCA52e7YndW1+x+t17Ptt2fE/+yWDRcviC3oI81Ebv6TT20MJ9/foCMZTbXi5Z Oyhg== MIME-Version: 1.0 X-Received: by 10.194.86.225 with SMTP id s1mr47628643wjz.21.1405621179380; Thu, 17 Jul 2014 11:19:39 -0700 (PDT) In-Reply-To: References: Date: Thu, 17 Jul 2014 14:19:39 -0400 Subject: Re: Blocked thread From: Larry Martell To: Chris Angelico Content-Type: text/plain; charset=UTF-8 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: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405621181 news.xs4all.nl 2924 [2001:888:2000:d::a6]:45047 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74664 On Thu, Jul 17, 2014 at 2:09 PM, Chris Angelico wrote: > 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. I do not think Oracle support async or non-blocking queries as Postgres does. But what I think I can do is not call join(), and just start monitoring the server when I kick off the thread with the mail sql it in.