Skip to main content

error-counter

Error Counter: Count error (e.g. network error) beyond process boundary, then issue fix command when exceeded threshold.

How to use

import requests
from error_counter import Counter

# reboot system when error accumulate 3 times in a low
network_error_counter = Counter("/tmp/network_error.txt")

try:
	r = requests.post(somowhere, somewhat)
except requests.ConnectionError as e:
	network_error_counter.inc_error()

if not r is None:
	# send succeeded.
	network_error_counter.reset_error()

Counter class

class Counter:
  def __init__(self, counterfile, reset_task="sudo reboot", reset_threshold=3):

#  counterfile: file name to use counter. The file is owned jointly by sevelal Counter beyond process boundary.

#  reset_task: shell command which is issued when error count is over the threshold.

#  reset_threshold: Threshold for reset_task.

  def inc_error(self):
  #	Increment error count then issue reset_task if count is over threshold

  def dec_error(self):
  # Decrement error count as 0

  def reset_error(self):
  # Reset error count as 0

downloads

Downloads Downloads Downloads

history

  • 0.1.0 2018.11.18 first version
  • 0.1.1 2018.11.18 fix README

Release files for error-counter 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for error-counter 0.1.1
File Size Uploaded
error_counter-0.1.1.tar.gz 2.1 kB Details

Release files / error_counter-0.1.1.tar.gz

Download URL error_counter-0.1.1.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5da6a15fa7b1827d67b2d66b1f04a09c1467ba13b5444994dfcf57757a386f66
BLAKE2b-256 checksum
How to use checksums
0705a4bc3c90a85f38ddf236eb07be465cda718d6e0625715f03742c2a23af30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.13

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page