def add_stock(symbol): if not symbol: return jsonify({ 'error': 'Stock symbol cannot be empty' }), 400 if symbol in symbols: pass else: symbol = symbol.encode('utf-8') symbols.add(symbol) logger.info('Add stock retrieve for %s' % symbol) schedule.add_job(fetch_price, 'interval', [symbol], seconds=1, id=symbol, max_instances=10) return jsonify(results=list(symbols)), 200
def backup_schedule(): schedule = BackgroundScheduler() schedule.start() schedule.add_job(test, 'cron', second="*/2", minute="*", hour="*", month="*", day="*", week="*") while True: pass
def add_running(symbol): symbols = set() if not symbol: return jsonify({'error': 'running symbol cannot be empty'}), 400 if symbol in symbols: pass else: symbol = symbol.encode('utf-8') symbols.add(symbol) logger.info('Add running retrieve job %s' % symbol) schedule.add_job(fetch_data, 'interval', [symbol], seconds=1, id=symbol) return jsonify(results=list(symbols)), 200
def dojob(): schedule = BlockingScheduler() schedule.add_job(func_stimr, 'interval', seconds=2, id='tt_job1') schedule.start()
# Post scheduled message to every user def scheduled_message(): for user_id in users: slack_web_client.api_call( "chat.postMessage", params=dict( as_user=True, channel=user_id, text="*rapor yolla reis* >> 20 saniye timerlı test mesajı")) schedule = BackgroundScheduler(daemon=True) schedule.add_job( scheduled_message, #trigger='interval', 'interval', next_run_time='2020-10-19 10:00:00', hours=1) schedule.start() for user_id in users: # Post a message to user daily_report_dm = slack_web_client.api_call( "chat.postMessage", params=dict( as_user=True, channel=user_id, text= "Hi! I'm BotBot. You can inform your teammates with using me about your mood, what you are doing now, what will you do and problems if there any. :v:\n\n", attachments=[{ "text":