from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.start()
def some_job():
print "Decorated job"
sched.add_interval_job(some_job,minutes=1)
> 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
A quick Google search suggests it's http://packages.python.org/APScheduler/
Cheers,
Chris
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.
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.
I see the latest version is APScheduler 1.3.1. Where can I get
APScheduler 2.0?
> 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.
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
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
> 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