summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2018-08-10 18:50:01 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2018-08-10 19:57:04 +0300
commitee7fbd65cb5e35ec26a50f3dbe23ba353e6b3227 (patch)
tree14c90b1527b4c3f5022e9ec610267d2999a00b0b
parentd21d02d016cbfe994c3908c182235e3152fafc7d (diff)
downloadapscheduler-ee7fbd65cb5e35ec26a50f3dbe23ba353e6b3227.tar.gz
Raise RuntimeError if starting the scheduler under uWSGI without threadsv3.5.2
-rw-r--r--apscheduler/schedulers/base.py11
-rw-r--r--docs/versionhistory.rst2
2 files changed, 13 insertions, 0 deletions
diff --git a/apscheduler/schedulers/base.py b/apscheduler/schedulers/base.py
index f7c65f7..8f910a6 100644
--- a/apscheduler/schedulers/base.py
+++ b/apscheduler/schedulers/base.py
@@ -127,11 +127,14 @@ class BaseScheduler(six.with_metaclass(ABCMeta)):
:param bool paused: if ``True``, don't start job processing until :meth:`resume` is called
:raises SchedulerAlreadyRunningError: if the scheduler is already running
+ :raises RuntimeError: if running under uWSGI with threads disabled
"""
if self.state != STATE_STOPPED:
raise SchedulerAlreadyRunningError
+ self._check_uwsgi()
+
with self._executors_lock:
# Create a default executor if nothing else is configured
if 'default' not in self._executors:
@@ -826,6 +829,14 @@ class BaseScheduler(six.with_metaclass(ABCMeta)):
except BaseException:
self._logger.exception('Error notifying listener')
+ def _check_uwsgi(self):
+ """Check if we're running under uWSGI with threads disabled."""
+ uwsgi_module = sys.modules.get('uwsgi')
+ if not getattr(uwsgi_module, 'has_threads', True):
+ raise RuntimeError('The scheduler seems to be running under uWSGI, but threads have '
+ 'been disabled. You must run uWSGI with the --enable-threads '
+ 'option for the scheduler to work.')
+
def _real_add_job(self, job, jobstore_alias, replace_existing):
"""
:param Job job: the job to add
diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst
index fc5f2d8..32b5843 100644
--- a/docs/versionhistory.rst
+++ b/docs/versionhistory.rst
@@ -11,6 +11,8 @@ APScheduler, see the :doc:`migration section <migration>`.
``YourClass.methodname`` along with an explicit ``self`` argument is no longer necessary as this
is now done automatically for you)
* Added the FAQ section to the docs
+* Made ``BaseScheduler.start()`` raise a ``RuntimeError`` if running under uWSGI with threads
+ disabled
3.5.1