Path: csiph.com!usenet.pasdenom.info!gegeweb.org!aioe.org!news.stack.nl!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'url:pypi': 0.03; 'hosts': 0.07; 'advice.': 0.09; 'way:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'thread': 0.14; '23,': 0.16; 'ah,': 0.16; 'cc:name:python list': 0.16; 'finishes': 0.16; 'heap': 0.16; 'ported': 0.16; 'wrote:': 0.18; 'library': 0.18; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'merge': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'apparently': 0.31; 'clock': 0.31; 'constant': 0.31; 'use?': 0.31; 'class': 0.32; 'maintaining': 0.32; 'another': 0.32; 'url:python': 0.33; 'could': 0.34; 'created': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'entry': 0.36; 'url:org': 0.36; 'implement': 0.38; 'nov': 0.38; 'url:library': 0.38; 'url:3': 0.61; '100': 0.79; 'polling': 0.84; 'yet?': 0.84; 'fibonacci': 0.91; 'lazy': 0.91; 'time)': 0.91 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=xVbTFeM+V/v03hdebpH0GeX5zySpR9AL0vxcnD8fw9s=; b=M6asVZkA9Ebh3g461q0lRLSHYKuEnTmMnXRWAdvGTWNwrKD0g4243XswxOqYNyWW1r N4THzyvJbMgKo+Q9vB3Gurq5IVZB7XgI91vxcVyug68KmdQpQEyGwh9JudRtvUD7YbNl Q5nvLroIf7NaAe/r30vQJ5HZQgUxQw6g3Z45qO3JPYdXaaUAQWKSNV+GnEi0XtkcTtCz UkBT2fmGEsWPg7f2DHSxVJj0do1TMT43Fs20/xxhLmcODJiPmtGBEu6BVnDIjPEzSZHl b/jcnApv793zEQ5Zng1WrUnrnfpSuJQ4YtuULA8pRA+E3EsjAI4cQU/rBSv3HFfpNmih oqXQ== MIME-Version: 1.0 X-Received: by 10.112.150.71 with SMTP id ug7mr16767707lbb.73.1416772617125; Sun, 23 Nov 2014 11:56:57 -0800 (PST) In-Reply-To: <0f947a1upejmd3376lbj7h33ejdsgv9msl@4ax.com> References: <4a496b58-867f-43ae-b6f9-48f4d885b170@googlegroups.com> <0f947a1upejmd3376lbj7h33ejdsgv9msl@4ax.com> Date: Sun, 23 Nov 2014 11:56:57 -0800 Subject: Re: Recurring Task From: Dan Stromberg To: Dennis Lee Bieber Content-Type: text/plain; charset=UTF-8 Cc: Python List 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416772625 news.xs4all.nl 2874 [2001:888:2000:d::a6]:49172 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81400 On Sun, Nov 23, 2014 at 10:35 AM, Dennis Lee Bieber wrote: > On Sun, 23 Nov 2014 07:23:43 -0800 (PST), tim@timothyarnold.co.uk declaimed > the following: > >>Hi All >>Looking for some advice. I'm creating a small netwok poller and wondered what people recommend to use? Will be polling up to 100 hosts every ten reconds or so >> > > Trickiest part would be maintaining the time-ordered queue (has Python > created a priority queue yet? -- Ah, apparently it has -- so one could use > the desired clock value for the priority, and when the thread finishes it > requeues incrementing the clock value by the rescan interval... -- you'd > need to implement a sleep_until if the thread grabs an entry before its > time) The standard library way: https://docs.python.org/3/library/queue.html Here's another way - a class I ported from Java: https://pypi.python.org/pypi/fibonacci-heap-mod The Fibonacci Heap is theoretically nice because it's lazy and supports some interesting operations like O(1) merge and O(1) decrease-key, but it has a large constant on its O(logn) dequeue-min.