MobileBlur

Diff
Login

Diff

Differences From Artifact [196ddfcd9f]:

To Artifact [bdd245f2ad]:


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
        lock is implemented by writing a pickle (start, stop) in cron.master
        start is time when cron job starts and stop is time when cron completed
        stop == 0 if job started but did not yet complete
        if a cron job started within less than 60 seconds, acquire returns None
        if a cron job started before 60 seconds and did not stop,
        a warning is issue "Stale cron.master detected"
        """
        if portalocker.LOCK_EX == None:
            logger.warning('WEB2PY CRON: Disabled because no file locking')
            return None
        self.master = open(self.path,'rb+')
        try:
            ret = None
            portalocker.lock(self.master,portalocker.LOCK_EX)
            try:







|







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
        lock is implemented by writing a pickle (start, stop) in cron.master
        start is time when cron job starts and stop is time when cron completed
        stop == 0 if job started but did not yet complete
        if a cron job started within less than 60 seconds, acquire returns None
        if a cron job started before 60 seconds and did not stop,
        a warning is issue "Stale cron.master detected"
        """
        if portalocker.LOCK_EX is None:
            logger.warning('WEB2PY CRON: Disabled because no file locking')
            return None
        self.master = open(self.path,'rb+')
        try:
            ret = None
            portalocker.lock(self.master,portalocker.LOCK_EX)
            try:
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
                    (proc.returncode, stdoutdata+stderrdata))
        else:
            logger.debug('WEB2PY CRON Call returned success:\n%s' \
                              % stdoutdata)

def crondance(applications_parent, ctype='soft', startup=False):
    apppath = os.path.join(applications_parent,'applications')
    cron_path = os.path.join(apppath,'admin','cron')
    token = Token(cron_path)
    cronmaster = token.acquire(startup=startup)
    if not cronmaster:
        return
    now_s = time.localtime()
    checks=(('min',now_s.tm_min),
            ('hr',now_s.tm_hour),







|







225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
                    (proc.returncode, stdoutdata+stderrdata))
        else:
            logger.debug('WEB2PY CRON Call returned success:\n%s' \
                              % stdoutdata)

def crondance(applications_parent, ctype='soft', startup=False):
    apppath = os.path.join(applications_parent,'applications')
    cron_path = os.path.join(applications_parent)
    token = Token(cron_path)
    cronmaster = token.acquire(startup=startup)
    if not cronmaster:
        return
    now_s = time.localtime()
    checks=(('min',now_s.tm_min),
            ('hr',now_s.tm_hour),
306
307
308
309
310
311
312
313


            try:
                cronlauncher(commands, shell=shell).start()
            except Exception, e:
                logger.warning(
                    'WEB2PY CRON: Execution error for %s: %s' \
                        % (task.get('cmd'), e))
    token.release()











>
>
306
307
308
309
310
311
312
313
314
315
            try:
                cronlauncher(commands, shell=shell).start()
            except Exception, e:
                logger.warning(
                    'WEB2PY CRON: Execution error for %s: %s' \
                        % (task.get('cmd'), e))
    token.release()