Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

apscheduler error

176 views
Skip to first unread message

linna li

unread,
Jan 7, 2011, 8:08:28 PM1/7/11
to
I tried to use the apscheduler and used the sample code below from the
tutorial, but got the error message: Exception in thread APScheduler
(most likely raised during interpreter shutdown). What's going on
here? I really appreciate any help!

from apscheduler.scheduler import Scheduler

sched = Scheduler()
sched.start()

def some_job():
print "Decorated job"

sched.add_interval_job(some_job,minutes=1)

Steven D'Aprano

unread,
Jan 7, 2011, 9:09:49 PM1/7/11
to
On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote:

> I tried to use the apscheduler and used the sample code below from the
> tutorial, but got the error message: Exception in thread APScheduler
> (most likely raised during interpreter shutdown). What's going on here?
> I really appreciate any help!


I've tried your code in every version of Python from 2.4 through 3.2, and
get an exception on the very first line every time:

ImportError: No module named apscheduler.scheduler


I think you will need to give some more detail... what version of Python
are you running, and what is apschedular?

Also, please copy and paste the exact error message, in full, including
the traceback. Don't summarise it, retype it, or paraphrase it.

--
Steven

Chris Rebert

unread,
Jan 7, 2011, 9:13:26 PM1/7/11
to Steven D'Aprano, pytho...@python.org
On Fri, Jan 7, 2011 at 6:09 PM, Steven D'Aprano
<steve+comp....@pearwood.info> wrote:
> On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote:
>> I tried to use the apscheduler and used the sample code below from the
>> tutorial, but got the error message: Exception in thread APScheduler
>> (most likely raised during interpreter shutdown). What's going on here?
>> I really appreciate any help!
>
>
> I've tried your code in every version of Python from 2.4 through 3.2, and
> get an exception on the very first line every time:
>
> ImportError: No module named apscheduler.scheduler
>
>
> I think you will need to give some more detail... what version of Python
> are you running, and what is apschedular?

A quick Google search suggests it's http://packages.python.org/APScheduler/

Cheers,
Chris

Adam Tauno Williams

unread,
Jan 7, 2011, 10:49:54 PM1/7/11
to pytho...@python.org

I see this same error when I run this code (python-2.6.5-3.3.1.x86_64)

I develop an application that uses APScheduler
<http://pypi.python.org/pypi/APScheduler/1.0>, the scheduler works very
well. But I haven't used it in exactly this manner.

If I add -
import time
time.sleep(300)
- to the end of your script I don't get the error; and the job actually
gets run [the scheduler thread won't stop the main thread, and thus the
script, from exiting].

The author of APScheduler has an eponymously named channel on FreeNode,
he can probably answer your question exactly.

Alice Bevan–McGregor

unread,
Jan 8, 2011, 2:03:58 AM1/8/11
to pytho...@python.org
Howdy!

On 2011-01-07 17:08:28 -0800, linna li said:
> I tried to use the apscheduler and used the sample code below from the
> tutorial, but got the error message: Exception in thread APScheduler
> (most likely raised during interpreter shutdown). What's going on here?
> I really appreciate any help!

After talking a bit with Alex Grönholm it seems this is an issue raised
fairly often (not always in the context of this package) and is not
really a problem with APScheduler. It has far more to do with
attempting to start a thread, then immediately exiting the main thread.
That's not how threading is supposed to be used, so don't do it. ;)

APScheduler 2.0 adds some improved examples, according to Alex, that
don't suffer the "problem" demonstrated by the short code snippit you
provided.

A package of mine, TurboMail, suffers from the same threading issue if
used improperly; you enqueue e-mail, it starts a thread, then you
immediately exit. TM tries to work around the issue, but in most cases
that workaround does not work properly. (You get strange uncatchable
exceptions printed on stderr though AFIK the e-mail does get sent
correctly, your application may hang waiting for the thread pool to
drain if you have a "minimum thread count" option set.)

I hope this clears things up a bit,

- Alice.


linna li

unread,
Jan 10, 2011, 8:19:10 PM1/10/11
to
Thank you for all the replies here! I will try your suggestions.

linna li

unread,
Jan 10, 2011, 8:23:34 PM1/10/11
to
On Jan 7, 11:03 pm, Alice Bevan–McGregor <al...@gothcandy.com> wrote:

I see the latest version is APScheduler 1.3.1. Where can I get
APScheduler 2.0?

Alice Bevan–McGregor

unread,
Jan 10, 2011, 10:46:33 PM1/10/11
to pytho...@python.org
On 2011-01-10 17:23:34 -0800, linna li said:

> I see the latest version is APScheduler 1.3.1. Where can I get APScheduler 2.0?

https://bitbucket.org/agronholm/apscheduler/

I don't think 2.0 has been released yet, but that is the version number
in apscheduler/__init__.py on HG tip. The examples, BTW, just add
time.sleep() calls. ;)

- Alice.


Hesham

unread,
Jan 13, 2011, 2:47:15 PM1/13/11
to
In cases like that instead of sleep() can use pause(). E.g.,

from apscheduler.scheduler import Scheduler
import signal

sched = Scheduler()
sched.start()
def some_job():
print "Decorated job"
sched.add_interval_job(some_job,minutes=1)

signal.pause()

Mosalam

Aahz

unread,
Jan 29, 2011, 4:53:36 PM1/29/11
to
In article <mailman.654.1294470...@python.org>,

=?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= <al...@gothcandy.com> wrote:
>
>A package of mine, TurboMail, suffers from the same threading issue if
>used improperly; you enqueue e-mail, it starts a thread, then you
>immediately exit. TM tries to work around the issue, but in most cases
>that workaround does not work properly. (You get strange uncatchable
>exceptions printed on stderr though AFIK the e-mail does get sent
>correctly, your application may hang waiting for the thread pool to
>drain if you have a "minimum thread count" option set.)

Why not write an exit handler that converts your thread to daemon? (Or
something like that.)
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of
indirection." --Butler Lampson

Ben Finney

unread,
Jan 29, 2011, 6:12:47 PM1/29/11
to
aa...@pythoncraft.com (Aahz) writes:

> In article <mailman.654.1294470...@python.org>,
> =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= <al...@gothcandy.com> wrote:
> >A package of mine, TurboMail, suffers from the same threading issue
> >if used improperly; you enqueue e-mail, it starts a thread, then you
> >immediately exit.
>

> Why not write an exit handler that converts your thread to daemon? (Or
> something like that.)

For that purpose, I'll ask that you try the ‘python-daemon’ library
<URL:http://pypi.python.org/pypi/python-daemon>. It's designed
specifically for making the current process into a well-behaved Unix
daemon.

--
\ “I knew things were changing when my Fraternity Brothers threw |
`\ a guy out of the house for mocking me because I'm gay.” |
_o__) —postsecret.com, 2010-01-19 |
Ben Finney

0 new messages