feigejafe / django-cron

Automatically exported from code.google.com/p/django-cron
MIT License
0 stars 0 forks source link

seems to break testing #25

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In my project I have one very simple test case. It runs fine.

But when I have djang_cron installed, the tests run fine, but ./manage.py tests 
fails to exit.

I see:
imac:server adam$ ./manage.py test gui
Creating test database for alias 'default'...
..
----------------------------------------------------------------------
Ran 2 tests in 0.028s

OK
Destroying test database for alias 'default'...

And it doesn't ever return - i need to ctrl-z/kill %1 to kill it.

 I have one cron job running every that is just:

from django_cron import cronScheduler, Job
from models import Session
from datetime import datetime

TIMEOUT = (60*5) # 5 mins

class CheckTimeouts(Job):    
    run_every = 60
                    def job(self):
        for s in Session.objects.filter(end_time = None ):
            if (datetime.now() - s.last_saved).seconds > TIMEOUT:
                s.end_time = s.last_saved
                s.save()

cronScheduler.register(CheckTimeouts)

The session filter in the scheduler doesn't return any objects in my database, 
so it isn't as though the job is running.

My guess is that the process is trying to exit at the end of the tests, but is 
waiting for threads to return.

Original issue reported on code.google.com by adamtw...@gmail.com on 2 Jun 2011 at 11:45

GoogleCodeExporter commented 8 years ago
Here's my diff to base.py to make it a daemon thread instead of 
threading.Timer() which solves the issue (see: 
http://stackoverflow.com/questions/5952910/python-cancel-timer-thread) for some 
background)::

Original comment by adamtw...@gmail.com on 2 Jun 2011 at 12:57

Attachments: