Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python.announce > #3403

Python Open-Source Snippets Newsletter

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From aswin@pythonninja.xyz
Newsgroups comp.lang.python.announce
Subject Python Open-Source Snippets Newsletter
Date Fri, 22 May 2020 16:43:16 -0400
Lines 44
Approved python-announce-list@python.org
Message-ID <79a60db1badf2259e4f97c7241227750@pythonninja.xyz> (permalink)
Reply-To python-list@python.org
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de /F88hpibYYDRfR8Qrq8Cngx22YRQdknf3G+FuDBcWLtg==
Authentication-Results mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=pythonninja.xyz header.i=@pythonninja.xyz header.b=CnWFklBH; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url-ip:140.82.118.3/32': 0.03; 'url-ip:140.82.118/24': 0.03; 'url-ip:140.82/16': 0.03; 'libraries.': 0.07; 'zero': 0.07; 'subject:Python': 0.09; 'http': 0.09; 'open-source': 0.09; 'requests.': 0.09; 'snippets': 0.09; 'subject:Open': 0.09; 'to:addr:python-announce-list': 0.09; 'url- ip:140/8': 0.12; 'python': 0.15; '"""': 0.16; 'iteration,': 0.16; 'subject:Newsletter': 0.16; 'url-ip:66/8': 0.16; 'url:repl': 0.16; 'url:subscribe': 0.16; 'url:github': 0.16; 'code': 0.28; 'link:': 0.31; 'url-ip:104.22/16': 0.32; 'header:User-Agent:1': 0.33; 'creating': 0.35; 'count': 0.36; 'request': 0.38; 'received:66': 0.39; 'useful': 0.40; 'hi,': 0.40; 'failed': 0.40; 'raise': 0.40; '50%': 0.62; 'received:us': 0.64; 'skip:g 30': 0.65; 'popular': 0.65; 'skip:t 20': 0.68; 'sleep': 0.69; 'criticism': 0.84; 'maps': 0.84; 'url:xyz': 0.86; 'demo': 0.91
DKIM-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pythonninja.xyz; s=default; h=Message-ID:Subject:To:From:Date: Content-Transfer-Encoding:Content-Type:MIME-Version:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8ue8GIaaUv/XsQeZ6wUYJlxhGn17fKns1cg1EAM4YtA=; b=CnWFklBHfxPhfPemg6q+71NRz XhPpHhVQNS258M5lbAohyplqMzWidjN55ZnjxP9OwFkDIsX3LuQLFx8uPWJcgguour/h1ku0aWs9y XTKR7HuIw4STx/s/ZkbQsj8gpPbq7iNMZvpJQPVRZI156xBd8SNAG/kp8o1tbR3lTtALsz/aRCFue RshGnKQKscctIHdbgrf3Heb1aJJQV1A2wGLHaBC2dQ5TdB60UfFN5TfXA2KQV6iOFPrCAvoh0RdFP +6rx8hqhEDxS3n2Q0m+pgpjWgKY9pZZC9GPXzMz6Nt5iVGOju1Qf6ytcudCJ0/zLG7IhWqESTeomW YyaV+f/QQ==;
X-Sender aswin@pythonninja.xyz
User-Agent Roundcube Webmail/1.3.8
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - oxygen.vhostplatform.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - pythonninja.xyz
X-Get-Message-Sender-Via oxygen.vhostplatform.com: authenticated_id: aswin@pythonninja.xyz
X-Authenticated-Sender oxygen.vhostplatform.com: aswin@pythonninja.xyz
X-Source
X-Source-Args
X-Source-Dir
X-MailFrom aswin@pythonninja.xyz
X-Mailman-Rule-Hits emergency
X-Mailman-Rule-Misses dmarc-mitigation; no-senders; approved
Message-ID-Hash NXJ2B6FKMWTVOUV7E4DMJZTYFQ4MXPML
X-Message-ID-Hash NXJ2B6FKMWTVOUV7E4DMJZTYFQ4MXPML
X-Mailman-Approved-At Fri, 22 May 2020 17:16:58 -0400
X-Mailman-Version 3.3.2b1
Precedence list
List-Id Announcement-only list for the Python programming language <python-announce-list.python.org>
Archived-At <https://mail.python.org/archives/list/python-announce-list@python.org/message/NXJ2B6FKMWTVOUV7E4DMJZTYFQ4MXPML/>
List-Archive <https://mail.python.org/archives/list/python-announce-list@python.org/>
List-Help <mailto:python-announce-list-request@python.org?subject=help>
List-Post <mailto:python-announce-list@python.org>
List-Subscribe <mailto:python-announce-list-join@python.org>
List-Unsubscribe <mailto:python-announce-list-leave@python.org>
Xref csiph.com comp.lang.python.announce:3403

Show key headers only | View raw


Hi,

I am creating a Python newsletter showcasing useful code snippets from 
popular open-source libraries. I will also be providing a runnable demo 
link to better understand the working.

Newsletter link: https://www.pythonninja.xyz/subscribe

A sample snippet from the newsletter:

HTTP Request retrying with Backoffs - Technique for retrying failed HTTP 
requests.

 From Google Maps Services Python 
(https://github.com/googlemaps/google-maps-services-python)

Demo link: https://repl.it/@PythonNinja/requestretries

"""
first_request_time: The time of the first request (None if no retries 
have occurred).
retry_counter: The count of retries, or zero for the first attempt.
"""

if not first_request_time:
     first_request_time = datetime.now()

elapsed = datetime.now() - first_request_time
if elapsed > self.retry_timeout:
     raise googlemaps.exceptions.Timeout()

if retry_counter > 0:
     # 0.5 * (1.5 ^ i) is an increased sleep time of 1.5x per iteration,
     # starting at 0.5s when retry_counter=0. The first retry will occur
     # at 1, so subtract that first.
     delay_seconds = 0.5 * 1.5 ** (retry_counter - 1)

     # Jitter this value by 50% and pause.
     time.sleep(delay_seconds * (random.random() + 0.5))


https://www.pythonninja.xyz/subscribe

Feedbacks and criticism are welcome.

Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread


Thread

Python Open-Source Snippets Newsletter aswin@pythonninja.xyz - 2020-05-22 16:43 -0400

csiph-web