Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'datetime.datetime' object has no attribute 'timestamp' #666

Closed
3 tasks done
jikong93 opened this issue Sep 19, 2022 · 4 comments
Closed
3 tasks done
Labels

Comments

@jikong93
Copy link

Things to check first

  • I have checked that my issue does not already have a solution in the FAQ

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Version

APScheduler 3.9.1

What happened?

D:\software\Python27\python.exe D:/pySpace/aps_test.py
Traceback (most recent call last):
File "D:/pySpace/aps_test.py", line 19, in
myAPS.start()
File "D:\software\Python27\lib\site-packages\apscheduler\schedulers\background.py", line 35, in start
BaseScheduler.start(self, *args, **kwargs)
File "D:\software\Python27\lib\site-packages\apscheduler\schedulers\base.py", line 167, in start
self._real_add_job(job, jobstore_alias, replace_existing)
File "D:\software\Python27\lib\site-packages\apscheduler\schedulers\base.py", line 863, in _real_add_job
replacements['next_run_time'] = job.trigger.get_next_fire_time(None, now)
File "D:\software\Python27\lib\site-packages\apscheduler\triggers\interval.py", line 68, in get_next_fire_time
return normalize(next_fire_time)
File "D:\software\Python27\lib\site-packages\apscheduler\util.py", line 431, in normalize
return datetime.fromtimestamp(dt.timestamp(), dt.tzinfo)
AttributeError: 'datetime.datetime' object has no attribute 'timestamp'

How can we reproduce the bug?


# coding=utf-8
from apscheduler.schedulers.background import BackgroundScheduler
import pytz
import datetime
import time


def my_task():
    print("task executed")



myAPS = BackgroundScheduler()
# 第6个月的第9天的每小时第3分钟第30秒执行,同时指定时区
myAPS.add_job(func=my_task, trigger="interval", seconds=3)


try:
    myAPS.start()
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    myAPS.shutdown()


pip list

Package Version


APScheduler 3.9.1
funcsigs 1.0.2
futures 3.3.0
pip 20.3.4
pytz 2022.2.1
setuptools 44.1.1
six 1.16.0
tzlocal 2.1

@jikong93 jikong93 added the bug label Sep 19, 2022
@agronholm
Copy link
Owner

This bug was introduced some time in the later releases, but since Python 2.7 reached its end of life almost 3 years ago, I decided not to spend a lot of time fixing it (my early attempts failed). If you are unable to switch to Python 3 for whatever reason, you need to downgrade your APScheduler to 3.8.1.

@agronholm agronholm closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2022
@jikong93
Copy link
Author

get, thanks
It is recommended that you can modify the version requirements

image

@jmath222
Copy link

Please update the version requirements on PyPI so that 3.9.1 doesn't appear as compatible with Python 2.7

@agronholm
Copy link
Owner

agronholm commented Nov 11, 2022

I've made new post-releases for v3.9.0 and v3.9.1 (and yanked the originals).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants