{"action":"created","issue":{"url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler/issues/94","repository_url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler","labels_url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler/issues/94/comments","events_url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler/issues/94/events","html_url":"https://github.com/viniciuschiele/flask-apscheduler/issues/94","id":381019270,"node_id":"MDU6SXNzdWUzODEwMTkyNzA=","number":94,"title":"get error: 'APScheduler' object has no attribute 'task'","user":{"login":"SSCedric","id":6848141,"node_id":"MDQ6VXNlcjY4NDgxNDE=","avatar_url":"https://avatars3.githubusercontent.com/u/6848141?v=4","gravatar_id":"","url":"https://api.github.com/users/SSCedric","html_url":"https://github.com/SSCedric","followers_url":"https://api.github.com/users/SSCedric/followers","following_url":"https://api.github.com/users/SSCedric/following{/other_user}","gists_url":"https://api.github.com/users/SSCedric/gists{/gist_id}","starred_url":"https://api.github.com/users/SSCedric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SSCedric/subscriptions","organizations_url":"https://api.github.com/users/SSCedric/orgs","repos_url":"https://api.github.com/users/SSCedric/repos","events_url":"https://api.github.com/users/SSCedric/events{/privacy}","received_events_url":"https://api.github.com/users/SSCedric/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-15T06:31:19Z","updated_at":"2018-11-28T09:19:33Z","closed_at":"2018-11-15T09:54:42Z","author_association":"NONE","body":"my demo struct\r\n```\r\n.\r\n├── app\r\n│   ├── api_1_0\r\n│   │   ├── apis.py\r\n│   │   ├── __init__.py\r\n│   │   └── __pycache__\r\n│   │       ├── apis.cpython-36.pyc\r\n│   │       ├── __init__.cpython-36.pyc\r\n│   │       └── test.cpython-36.pyc\r\n│   ├── __init__.py\r\n│   ├── models.py\r\n│   ├── __pycache__\r\n│   │   ├── __init__.cpython-36.pyc\r\n│   │   ├── models.cpython-36.pyc\r\n│   │   └── response.cpython-36.pyc\r\n│   ├── response.py\r\n│   ├── static\r\n│   │   ├── css\r\n│   │   ├── fonts\r\n│   │   ├── images\r\n│   │   └── js\r\n│   ├── templates\r\n│   └── utils\r\n│       ├── id_generator.py\r\n│       ├── __init__.py\r\n│       ├── __pycache__\r\n│       │   ├── id_generator.cpython-36.pyc\r\n│       │   └── __init__.cpython-36.pyc\r\n│       └── scheduler_tasks.py\r\n├── config.py\r\n├── dependences.py\r\n├── manager_dev.py\r\n├── manager.py\r\n├── __pycache__\r\n│   └── config.cpython-36.pyc\r\n├── readme.md\r\n├── requirements.txt\r\n└── uwsgi\r\n    └── uwsgi_pro.ini\r\n```\r\n\r\ncontent of config.py\r\n\r\n```\r\nimport os\r\nfrom apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore\r\n\r\nclass Config(object):\r\n    CACHE_CONFIG = {\r\n            'CACHE_TYPE': 'simple',\r\n            'CACHE_THRESHOLD': 1024,\r\n            'CACHE_DEFAULT_TIMEOUT': 60*5\r\n            }\r\n\r\nclass DevConfig(Config):\r\n    # 数据库信息从环境变量取\r\n    #SQLALCHEMY_DATABASE_URI = os.environ.get('key')\r\n    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://demo:demo_pwd@localhost:3306/demo'\r\n    SCHEDULER_API_ENABLED = True\r\n    SCHEDULER_JOBSTORES = {\r\n            'default': SQLAlchemyJobStore(SQLALCHEMY_DATABASE_URI)\r\n            }\r\n    SQLALCHEMY_COMMIT_ON_TEARDOWN = True\r\n    SQLALCHEMY_POOL_SIZE = 50\r\n    SQLALCHEMY_POOL_TIMEOUT = 10\r\n    SQLALCHEMY_POOL_RECYCLE = 60*10\r\n    SQLALCHEMY_MAX_OVERFLOW = 150\r\n    SQLALCHEMY_TRACK_MODIFICATIONS = True\r\n    SQLALCHEMY_ECHO = True\r\n    DEBUG = True\r\n\r\nclass ProConfig(Config):\r\n    # 数据库信息从环境变量取\r\n    #SQLALCHEMY_DATABASE_URI = os.environ.get('key')\r\n    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://demo:demo_pwd@localhost:3306/demo'\r\n    SCHEDULER_API_ENABLED = True\r\n    SCHEDULER_JOBSTORES = {\r\n            'default': SQLAlchemyJobStore(SQLALCHEMY_DATABASE_URI)\r\n            }\r\n    SQLALCHEMY_COMMIT_ON_TEARDOWN = True\r\n    SQLALCHEMY_POOL_SIZE = 50\r\n    SQLALCHEMY_POOL_TIMEOUT = 10\r\n    SQLALCHEMY_POOL_RECYCLE = 60*10\r\n    SQLALCHEMY_MAX_OVERFLOW = 50\r\n    DEBUG = False\r\n\r\nconfig = {\r\n            'dev' : DevConfig,\r\n            'pro' : ProConfig,\r\n            'default' : DevConfig\r\n         }\r\n```\r\n\r\ncontent of app/__init__py\r\n\r\n```\r\nfrom flask import Flask\r\nfrom flask_sqlalchemy import SQLAlchemy\r\nfrom flask_cache import Cache\r\nfrom config import config\r\nfrom flask_apscheduler import APScheduler\r\n\r\ndb = SQLAlchemy()\r\ncache = Cache()\r\nscheduler = APScheduler()\r\n\r\ndef create_app(config_name):\r\n    app = Flask(__name__)\r\n    app.config.from_object(config[config_name])\r\n\r\n    db.init_app(app)\r\n\r\n    cache_config = config[config_name].CACHE_CONFIG\r\n    cache.init_app(app, config=cache_config)\r\n\r\n    scheduler.init_app(app)\r\n    scheduler.start()\r\n\r\n    from .api_1_0 import api\r\n    app.register_blueprint(api, url_prefix='/api/')\r\n\r\n    return app\r\n```\r\n\r\ncontent of app/api_1_0/apis.py\r\n\r\n```\r\nfrom . import api\r\nimport requests as req\r\nfrom ..models import * \r\nfrom ..response import Response\r\nfrom .. import cache\r\nfrom time import sleep\r\nfrom datetime import datetime\r\nfrom .. import scheduler\r\n\r\n@scheduler.task(\"interval\", id=\"do_job_1\", seconds=15, misfire_grace_time=900)\r\ndef job_1():\r\n    print('{} start task'.format(datetime.now()))\r\n    time.sleep(10)\r\n    print('{} end task'.format(datetime.now()))\r\n```\r\n\r\nwhat i got:\r\n```\r\n(.venv) [root@abc flask_template]# python manager_dev.py runserver\r\nTraceback (most recent call last):\r\n  File \"manager_dev.py\", line 5, in <module>\r\n    app = create_app('dev')\r\n  File \"/prj/dev/flask_template/app/__init__.py\", line 23, in create_app\r\n    from .api_1_0 import api\r\n  File \"/prj/dev/flask_template/app/api_1_0/__init__.py\", line 5, in <module>\r\n    from . import apis\r\n  File \"/prj/dev/flask_template/app/api_1_0/apis.py\", line 33, in <module>\r\n    @scheduler.task(\"interval\", id=\"do_job_1\", seconds=15, misfire_grace_time=900)\r\nAttributeError: 'APScheduler' object has no attribute 'task'\r\n(.venv) [root@guorou flask_template]# python manager_dev.py runserver\r\nTraceback (most recent call last):\r\n  File \"manager_dev.py\", line 5, in <module>\r\n    app = create_app('dev')\r\n  File \"/prj/dev/flask_template/app/__init__.py\", line 23, in create_app\r\n    from .api_1_0 import api\r\n  File \"/prj/dev/flask_template/app/api_1_0/__init__.py\", line 5, in <module>\r\n    from . import apis\r\n  File \"/prj/dev/flask_template/app/api_1_0/apis.py\", line 33, in <module>\r\n    @scheduler.task(\"interval\", id=\"do_job_1\", seconds=15, misfire_grace_time=900)\r\nAttributeError: 'APScheduler' object has no attribute 'task'\r\n```"},"comment":{"url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler/issues/comments/442376326","html_url":"https://github.com/viniciuschiele/flask-apscheduler/issues/94#issuecomment-442376326","issue_url":"https://api.github.com/repos/viniciuschiele/flask-apscheduler/issues/94","id":442376326,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MjM3NjMyNg==","user":{"login":"CptJason","id":397285,"node_id":"MDQ6VXNlcjM5NzI4NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/397285?v=4","gravatar_id":"","url":"https://api.github.com/users/CptJason","html_url":"https://github.com/CptJason","followers_url":"https://api.github.com/users/CptJason/followers","following_url":"https://api.github.com/users/CptJason/following{/other_user}","gists_url":"https://api.github.com/users/CptJason/gists{/gist_id}","starred_url":"https://api.github.com/users/CptJason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CptJason/subscriptions","organizations_url":"https://api.github.com/users/CptJason/orgs","repos_url":"https://api.github.com/users/CptJason/repos","events_url":"https://api.github.com/users/CptJason/events{/privacy}","received_events_url":"https://api.github.com/users/CptJason/received_events","type":"User","site_admin":false},"created_at":"2018-11-28T09:19:33Z","updated_at":"2018-11-28T09:19:33Z","author_association":"NONE","body":"Hello @SSCedric \r\nWhy did you closed this issue? Have it fixed?"}}
{"actor":{"display_login":"CptJason"}}