exceptionalpy
features
-
exception handling decorator (ex / catch)
-
timing decorator (ti / timeit)
-
exception handling and timing decorator (exti / catch_timeit)
-
Handler
- handle exceptions
- print stacktrace
- forward stacktrace to notifier
- handle timing results of functions
- forward to notifier
- handle exceptions
-
BaseNotifier
- provide interface for extensions
-
HTTPNotifier
- send stacktrace via POST to specified url
-
SMTPNotifier
- send stacktrace via Mail to specified email addresses
-
Rescuer
- Manager like interface for threads / processes
- Capture exceptions
usage
basic
import time
from exceptionalpy import catch, timeit, exceptionalpy_handler as handler
handler.verbose = True # since you probably want to see your timing results
@timeit()
def gotta_work_fast():
time.sleep(0.4)
@catch()
def cant_fail():
raise ArithmeticError
gotta_work_fast()
# gotta_work_fast completed in 400432710 ns | 400.43271 ms | 0.40043270999999997 s
cant_fail()
# prints stacktrace
print("I will still be printed.")
print("Since the program will not exit even though an exception occurred.")
extensive guide
import time
from exceptionalpy import ex, exceptionalpy_handler as handler
# lets be verbose
handler.verbose = True
# you can either just catch all exceptions with
handler.init()
# and then stop again with
handler.deinit()
# or you can decorate the functions of which you want the exceptions to be caught
@ex()
def i_will_throw():
raise BaseException
# there is also a timing decorator that catches the exception
from exceptionalpy import exti
@exti()
def i_take_a_moment_to_throw():
time.sleep(0.6)
print("Heyyyyy")
raise ArithmeticError
# if you still want to time your functions and
# have the result be forwarded to the notifier
from exceptionalpy import ti
@ti()
def i_take_a_moment():
time.sleep(0.4)
print("Slow function here, hi")
i_take_a_moment()
# upon successful execution, if you set the handlers verbose option to True,
# you will see something like this
# i_take_a_moment completed in 400432710 ns | 400.43271 ms | 0.40043270999999997 s
# and that result will be jsonified and forwarded to the notifier
# before any exceptions happen, you can also attach a notifier
from exceptionalpy.HTTP import HTTPNotifier
handler.notifier = HTTPNotifier("https://my-server:1337/api/exceptional", "POST")
# or just use a completely different handler
from exceptionalpy.SMTP import SMTPSHandler
handler = SMTPSHandler(("127.0.0.1", 25), # which SMTP server to use
"exceptionalpy@locahost", # the sender address
"dev@localhost", # the receiver address
"There was an exception in your program") # the subject
# nothing bad will happen if you don't call
handler.deinit()
# beforehand. you can do it, but it's a waste of cpu cycles.
i_will_throw()
print("I will still be printed")
i_take_a_moment_to_throw()
print("I get printed as well since the program does not exit")
Metadata
Release files for exceptionalpy 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| exceptionalpy-0.4.tar.gz | 5.9 kB | Without provenance | Details for exceptionalpy-0.4.tar.gz |
Release files / exceptionalpy-0.4.tar.gz
| Download URL | exceptionalpy-0.4.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9173dcda164b7ebbc521661677cb3edb0db80af0d1fc4f740b08cf6ac5a9c46d
|
|
BLAKE2b-256 checksum How to use checksums |
b833883afc56520d62af2a5f36cfa839de6557777fd0a14705347910fc1bb598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for exceptionalpy 0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.