apscheduler error

Discussion in 'Python' started by linna li, Jan 8, 2011.

  1. linna li

    linna li Guest

    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)
     
    linna li, Jan 8, 2011
    #1
    1. Advertising

  2. 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
     
    Steven D'Aprano, Jan 8, 2011
    #2
    1. Advertising

  3. linna li

    Chris Rebert Guest

    On Fri, Jan 7, 2011 at 6:09 PM, Steven D'Aprano
    <> 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
     
    Chris Rebert, Jan 8, 2011
    #3
  4. On Fri, 2011-01-07 at 17:08 -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!
    >
    > 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.
     
    Adam Tauno Williams, Jan 8, 2011
    #4
  5. 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.
     
    Alice Bevan–McGregor, Jan 8, 2011
    #5
  6. linna li

    linna li Guest

    Thank you for all the replies here! I will try your suggestions.

    On Jan 7, 11:03 pm, Alice Bevan–McGregor <> wrote:
    > 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, Jan 11, 2011
    #6
  7. linna li

    linna li Guest

    On Jan 7, 11:03 pm, Alice Bevan–McGregor <> wrote:
    > 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.


    I see the latest version is APScheduler 1.3.1. Where can I get
    APScheduler 2.0?
     
    linna li, Jan 11, 2011
    #7
  8. 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.
     
    Alice Bevan–McGregor, Jan 11, 2011
    #8
  9. linna li

    Hesham Guest

    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
     
    Hesham, Jan 13, 2011
    #9
  10. linna li

    Aahz Guest

    In article <>,
    =?utf-8?Q?Alice_Bevan=E2=80=93McGregor?= <> 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 () <*> http://www.pythoncraft.com/

    "All problems in computer science can be solved by another level of
    indirection." --Butler Lampson
     
    Aahz, Jan 29, 2011
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,752
  2. JavaQueries
    Replies:
    1
    Views:
    3,771
    John C. Bollinger
    Mar 1, 2005
  3. Balaji
    Replies:
    3
    Views:
    10,201
  4. Bishop
    Replies:
    1
    Views:
    832
    Bishop
    Feb 24, 2007
  5. juvi
    Replies:
    3
    Views:
    1,083
    Alexey Smirnov
    Jan 22, 2009
Loading...

Share This Page