Hello,

I'm trying to implement a background asynchronous task. To this end, I've installed the "Background Process" module (http://drupal.org/project/background_process). In the front-page documentation, I see the following example:

$handle = background_process_start('mymodule_dosomething', $myvar1, $myvar2);

I have a simple function test_task2() (that runs fine from the linux command line) but I keep getting errors: "Callback: test_task2 not found" in my admin/reports/dblog when executing the above code.

Generally, I want to run a background task that may take 10 minutes and update my module's Drupal tables.

Does anyone know what to put in the first argument of background_process_start() to execute my code? (Searched everywhere and looked at source code but couldn't figure out the developer's intent.)

Or does anyone know of a better way to run long background tasks that may be executed manually or as a CRON job?

Comments

jaypan’s picture

You showed us a piece of code that says nothing about test_task2() and an error that only says something about test_task2(). Your code also shows a callback of mymodule_dosomething(), but you have not shown us the code for mymodule_dosomething(). I'm sure you can appreciate that it's hard to debug code we cannot see, from a piece of code that doesn't tell us anything.

Contact me to contract me for D7 -> D10/11 migrations.

jpvivere’s picture

Thanks for replying. That's a good point.

One of the developers wrote back and gave me a hint. It turns out that the 'mymodule_dosomething()' function (or whatever you name it) must be in the .module file, not in another .inc file of my making (even though the .inc file is included in the .info file).

kerby70’s picture

Very good to know.

willvincent’s picture

It probably could be in an include file if you explicitly do a require, or in hoot_init() do a module_load_include()

Follow me on twitter.