Flask Task Monitor
A flask plugin to monitor thread task
How to use
Install
To install from source, download the source code, then run this:
python setup.py install
Or install with pip:
pip install Flask-Task-Monitor
Setup
Adding the extension to your Flask app is simple:
from flask import Flask
from flask_monitor import Monitor
monitor = Monitor(config={
'FLASK_MONITOR_PERIOD': 1
})
app = Flask(__name__)
monitor.init_app(app)
Add monitered task with database
from flask_monitor import DBMonitor
from yourapplication import monitor
class DemoMonitorJob(DBMonitor):
def __init__(self, a, b, c):
super(DemoMonitorJob, self).__init__()
pass
@classmethod
def redo(cls, *args, **kwargs):
'''
execute when your job is crashed
'''
pass
@classmethod
def roll_back(cls, *args, **kwargs):
'''
execute after redo when catch exception
'''
pass
def do(self, *args, **kwargs):
'''your own job which needs to monitered
'''
pass
monitor.add_check_monitor(DemoMonitorJob)
Your own monitor
You can code your own monitor by redis, zookeeper, etcd and more
from flask_monitor import BaseMonitorInterface
class YourMonitor(BaseMonitorInterface):
def lock(self, *args, **kwargs):
'''
when called your do function
'''
pass
def unlock(self, args, **kwargs):
'''
when your do function return
'''
pass
@classmethod
def check(cls, *args, **kwargs):
'''
your own check function: it will return to
try:
redo(list, dict)
except Expection:
rollback(list,dict)
'''
return list, dict
@abstractmethod
def do(self, *args, **kwargs):
pass
@classmethod
@abstractmethod
def redo(self, *args, **kwargs):
pass
@classmethod
@abstractmethod
def rollback(self, *args, **kwargs):
pass
Metadata
Release files for Flask-Task-Monitor 2.0
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 | |
|---|---|---|---|---|
| Flask-Task-Monitor-2.0.tar.gz | 72.2 kB | Without provenance | Details |
Release files / Flask-Task-Monitor-2.0.tar.gz
| Download URL | Flask-Task-Monitor-2.0.tar.gz |
|---|---|
| Size | 72.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49fc844943c64f2716d71bd1170ce572e213ee1cf4bf011407e6abdfce2f3968
|
|
BLAKE2b-256 checksum How to use checksums |
c8580de6a71cc3f3309d1cc27cb0fef4bfb963f5bd8212d213d4ccf0d0d7d652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.6.5
|
Security for Flask-Task-Monitor 2.0
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.