question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

/shceduler/job Error:Object of type APScheduler is not JSON serializable

See original GitHub issue

When i use the demo from basic example,it worked. But when i add one job with the args which the initialize scheduler,like this: @scheduler.task('cron', id='refresh_job', minute='*/1',args=[scheduler]) def refresh_job(scheduler): jobs = scheduler.get_jobs() print(jobs) the job worked,and when i use Postman,i got an Error image this is Error Message in server [2021-02-24 19:09:51,219] ERROR in app: Exception on /scheduler/jobs [GET] Traceback (most recent call last): File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask_apscheduler/scheduler.py", line 373, in decorated return view_func(*args, **kwargs) File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask_apscheduler/api.py", line 82, in get_jobs return jsonify(job_states) File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask_apscheduler/json.py", line 23, in jsonify return flask.current_app.response_class(dumps(data, indent=indent), status=status, mimetype='application/json') File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask_apscheduler/json.py", line 16, in dumps return json.dumps(obj, indent=indent, cls=JSONEncoder) File "/Users/goshoho/anaconda3/lib/python3.8/json/__init__.py", line 234, in dumps return cls( File "/Users/goshoho/anaconda3/lib/python3.8/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/Users/goshoho/anaconda3/lib/python3.8/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/Users/goshoho/anaconda3/lib/python3.8/site-packages/flask_apscheduler/json.py", line 34, in default return super(JSONEncoder, self).default(obj) File "/Users/goshoho/anaconda3/lib/python3.8/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type APScheduler is not JSON serializable 127.0.0.1 - - [24/Feb/2021 19:09:51] "GET /scheduler/jobs HTTP/1.1" 500 -

May be the sheduler can’t be serializable? i just want cyclical refresh my job list with timing,if there have another solution,it’s also grate for me!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
zexpecommented, Mar 27, 2022

I’ve started using flask-apscheduler for a project and have encountered the same problem. My jobs have various objects passed to them that are not JSON serialisable and cannot be easily made so. The jobs all run without any problems. However, I cannot see what jobs are currently scheduled from the API due to this error occurring. I have no interest in seeing the argument values passed through to the jobs from the API - only which ids are currently scheduled, and when they are scheduled to run. Is it possible to have an option to display a less verbose set of details on the jobs from the API to avoid the need to JSON serialise the arguments?

0reactions
qfgrubbycommented, Nov 24, 2022

I can access http://ipaddr:port/scheduler, but cannot access http://ipaddr:port/scheduler/jobs It shows “TypeError: Object of type AppDeploy is not JSON serializable” error. How to solve this?

I found the solution myself. It was caused by JSON format. File was json.py that existed in flask_apscheduler package. Commented this return " #return super(JSONEncoder, self).default(obj)". It’s ok now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object of type 'TypeError' is not JSON serializable
I try to build API with Django rest framework. And I got Object of type ' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found