<div class="uk-width-1-4 start-time-div">
<label class="uk-form-label uk-display-block">Start Time</label>
<div class="uk-form-controls uk-clearfix">
<div class="yn_formdatewrap">
<div class="uk-form-icon uk-form-icon-flip uk-width-1-1">
<i class="yash_icons yash-ion-android-time"></i>
<input type="text" name="start_time[]" placeholder="Start Time" data-uk-timepicker="{format:'12h'}"
class="uk-width-1-1 yn_formcommon yn_formtext timing-req start_time">
</div>
</div>
</div>
</div>
<div class="uk-width-1-4 end-time-div">
<label class="uk-form-label uk-display-block">End Time</label>
<div class="uk-form-controls uk-clearfix">
<div class="yn_formdatewrap">
<div class="uk-form-icon uk-form-icon-flip uk-width-1-1">
<i class="yash_icons yash-ion-android-time"></i>
<input type="text" name="end_time[]" placeholder="End Time" data-uk-timepicker="{format:'12h'}"
class="uk-width-1-1 yn_formcommon yn_formtext timing-req end_time">
</div>
</div>
</div>
</div>
------- CELERY CONFIGS -------
import argparse
from flask import Flask
from celery import Celery
app = Flask(__name__)
parser = argparse.ArgumentParser(prog="testpgm")
parser.add_argument('-c','--cfgfile', default='domain.ini', help="provide ini file path")
parser.add_argument('-p','--port', default=5000, help="-p port number eg - 'python run.py -p <port>, default to 5000")
args = parser.parse_args()
ini_path = args.cfgfile
port = args.port
但是当我使用
运行芹菜时app.config["CELERY_QUEUES"] = (
Queue('queue1', Exchange('queue1'), routing_key='queue1')
)
def make_celery(flaskapp):
#getting celery broker uri
celery_broker_uri= CeleryBrokerWrapper().get_broker_uri(broker,username,password,host,port,vhost)
celeryinit = Celery(flaskapp.import_name, broker=celery_broker_uri)
celeryinit.conf.update(flaskapp.config)
taskbase = celeryinit.Task
class ContextTask(taskbase):
abstract = True
def __call__(self, *args, **kwargs):
with app.app_context():
return taskbase.__call__(self, *args, **kwargs)
celeryinit.Task = ContextTask
return celeryinit
celery = make_celery(app)
我收到错误
celery -A testpgm.celery worker --loglevel=info --concurrency=5 -Q queue1
它看起来像一个argparse错误,如何为我的应用程序自定义argparse,而没有芹菜的命令行参数问题..
答案 0 :(得分:2)
你需要重新订购args:
celery worker -A testpgm.celery --loglevel=info --concurrency=5 -Q queue1
答案 1 :(得分:1)
有一个类似的问题,argparse也抱怨我。
快速修复:使用parse_known_args,而不是parse_args
args, unknown = parser.parse_known_args()
源: Python argparse ignore unrecognised arguments
丑陋的修复: 定义芹菜工人args作为你的主应用程序的argparse的一部分
“做得对”修复: 考虑在主函数中使用argparse,以便芹菜不会与它发生冲突