starting to figure this out

This commit is contained in:
root 2020-08-27 14:02:19 +01:00
parent 26bb885801
commit 0bb7656c00
4 changed files with 40 additions and 2 deletions

2
app/callbacks.py Normal file
View File

@ -0,0 +1,2 @@
class CbJob:
def status(): pass

7
app/log.py Normal file
View File

@ -0,0 +1,7 @@
class FeLog:
def _log (self, sev, msg): print("%s: %s" % (sev, msg))
def debug (self, msg): self._log('DEBG', msg)
def verbose (self, msg): self._log('VERB', msg)
def info (self, msg): self._log('INFO', msg)
def warning (self, msg): self._log('WARN', msg)
def error (self, msg): self._log('ERR!', msg)

View File

@ -1,7 +1,30 @@
from flask import Flask
from flask_rq2 import RQ as Queue
from flask_rq2 import RQ as _RQ
from youtube_dl import YoutubeDL as YDL
from time import sleep
from .log import FeLog
from .callbacks import CbJob
BaseYDLOpts={
'no_color': True,
'call_home': False,
'logger': FeLog(),
'progress_hooks': {
'status': CbJob.status,
},
}
app=Flask(__name__)
q=Queue(app)
RQ=_RQ(app)
@RQ.job('test', timeout=30)
def DeliberatelyTimesOut():
sleep(35)
@app.route('/')
def index(): return 'hewwo'
@app.route('/add/timeouttest')
def timeouttest():
j=DeliberatelyTimesOut.queue()
return 'queued'

6
requirements.txt Normal file
View File

@ -0,0 +1,6 @@
Flask~=1.1.2
Flask-RQ2>=18.3
rq~=1.5.1
rq-dashboard>=0.6.1
rq-scheduler>=0.10.0
youtube-dl>=2020.7.28