diff options
Diffstat (limited to 'apscheduler')
-rw-r--r-- | apscheduler/__init__.py | 4 | ||||
-rw-r--r-- | apscheduler/jobstores/base.py | 6 | ||||
-rw-r--r-- | apscheduler/jobstores/sqlalchemy.py | 7 | ||||
-rw-r--r-- | apscheduler/util.py | 14 |
4 files changed, 24 insertions, 7 deletions
diff --git a/apscheduler/__init__.py b/apscheduler/__init__.py index fbaf967..c586865 100644 --- a/apscheduler/__init__.py +++ b/apscheduler/__init__.py @@ -1,5 +1,5 @@ -version_info = (3, 0, 0, 'b2') +version_info = (3, 0, 0, 'rc1') version = '3.0.0' -release = '3.0.0b2' +release = '3.0.0rc1' __version__ = release # PEP 396 diff --git a/apscheduler/jobstores/base.py b/apscheduler/jobstores/base.py index 7ac44c3..e09e40a 100644 --- a/apscheduler/jobstores/base.py +++ b/apscheduler/jobstores/base.py @@ -65,7 +65,8 @@ class BaseJobStore(six.with_metaclass(ABCMeta)): @abstractmethod def get_due_jobs(self, now): """ - Returns the list of jobs that have ``next_run_time`` earlier or equal to ``now``, sorted by next run time + Returns the list of jobs that have ``next_run_time`` earlier or equal to ``now``. + The returned jobs must be sorted by next run time (ascending). :param datetime.datetime now: the current (timezone aware) datetime :rtype: list[Job] @@ -82,7 +83,8 @@ class BaseJobStore(six.with_metaclass(ABCMeta)): @abstractmethod def get_all_jobs(self): """ - Returns a list of all contained jobs (sorted by next run time). + Returns a list of all jobs in this job store. The returned jobs should be sorted by next run time (ascending). + Paused jobs (next_run_time == None) should be sorted last. The job store is responsible for setting the ``scheduler`` and ``jobstore`` attributes of the returned jobs to point to the scheduler and itself, respectively. diff --git a/apscheduler/jobstores/sqlalchemy.py b/apscheduler/jobstores/sqlalchemy.py index f1692a5..4e0c0e2 100644 --- a/apscheduler/jobstores/sqlalchemy.py +++ b/apscheduler/jobstores/sqlalchemy.py @@ -10,7 +10,7 @@ except ImportError: # pragma: nocover import pickle try: - from sqlalchemy import create_engine, Table, Column, MetaData, Unicode, BigInteger, LargeBinary, select + from sqlalchemy import create_engine, Table, Column, MetaData, Unicode, Float, LargeBinary, select from sqlalchemy.exc import IntegrityError except ImportError: # pragma: nocover raise ImportError('SQLAlchemyJobStore requires SQLAlchemy installed') @@ -44,10 +44,11 @@ class SQLAlchemyJobStore(BaseJobStore): else: raise ValueError('Need either "engine" or "url" defined') + # 767 = max key length in MySQL for InnoDB tables, 25 = precision that translates to an 8-byte float self.jobs_t = Table( tablename, metadata, - Column('id', Unicode(1024, _warn_on_bytestring=False), primary_key=True), - Column('next_run_time', BigInteger, index=True), + Column('id', Unicode(767, _warn_on_bytestring=False), primary_key=True), + Column('next_run_time', Float(25), index=True), Column('job_state', LargeBinary, nullable=False) ) diff --git a/apscheduler/util.py b/apscheduler/util.py index 1544910..9396593 100644 --- a/apscheduler/util.py +++ b/apscheduler/util.py @@ -136,11 +136,25 @@ def convert_to_datetime(input, tz, arg_name): def datetime_to_utc_timestamp(timeval): + """ + Converts a datetime instance to a timestamp. + + :type timeval: datetime + :rtype: float + """ + if timeval is not None: return timegm(timeval.utctimetuple()) + timeval.microsecond / 1000000 def utc_timestamp_to_datetime(timestamp): + """ + Converts the given timestamp to a datetime instance. + + :type timestamp: float + :rtype: datetime + """ + if timestamp is not None: return datetime.fromtimestamp(timestamp, utc) |