<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am not sure I understand the problem.<br>If you want to make sure only one process runs at a time, we can use a locking
<br>mechanism like I do in one module:<br><br>Making sure we get the lock prevents a race condition, a problem that make<br>poormanscron.module currently unuseable (see link in code comment).<br><br>/**<br> * Implementation of hook_cron().
<br> */<br>function hook_cron() {<br> // Check if we have another instance of cron running.<br> if (variable_get('hook_cron_running', 0)) {<br> return;<br> }<br> // hook_cron is not already running.<br> // See if we can get the lock before another process does.
<br> // Algorithm found here: <a href="http://drupal.org/node/43511">http://drupal.org/node/43511</a>.<br> $result = db_query("UPDATE {variable} SET value = 'i:1;' WHERE name =<br>'hook_cron_running' AND value = 'i:0;'");
<br> if (db_affected_rows() != 1) {<br> // We didn't get the lock. Another process outran us.<br> watchdog('hook_cron', 'This cron process was outraced.');<br> return;<br> }<br> // Do stuff here...
<br><br> // then, at the end:<br> // Unlock.<br> variable_set('hook_cron_running', 0);<br> return;<br>}<br></blockquote></div><br>Wouldn't the second process be blocked until the first one completes, instead
<br>of returning immediately? There is no equivalent to Oracle's NOWAIT in MySQL<br>as far as I recall.<br>-- <br><a href="http://2bits.com">2bits.com</a><br><a href="http://2bits.com">http://2bits.com</a><br>Drupal development, customization and consulting.