apscheduler error

L

linna li

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)
 
S

Steven D'Aprano

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.
 
C

Chris Rebert

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
 
A

Adam Tauno Williams

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)

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.
 
A

Alice Bevan–McGregor

Howdy!

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.
 
L

linna li

Howdy!



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.

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

Hesham

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
 
A

Aahz

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top