Forum OpenACS Development: Re: Res: Re: About code executed in a new thread

Collapse
Posted by Luis de la Fuente on
Thank you so much Dave, it works better now.

Another related question, about ns_thread and ad_schedule_proc

I am building a command in a variable to execute it later in a new thread. If I use ns_thread, it works. However I cannot make it work when using ad_schedule_proc with parameters.

Let's see a piece of code:
-------------
#build the command name
set command_name "imsld::gsi::${plugin}::check_requisites -petition_id $petition_id"

#reloads all the process in the file, even in threads
ns_eval {source /path/to/file.tcl}

#this line works, with ns_thread
ns_thread begindetached $command_name

#this line throws an error
ad_schedule_proc -thread t -once t 0 $command_name
##The error is:
##invalid command name imsld::gsi::clk::check_requisites -petition_id 1"
-------------

However, If I build 'command_name' without parameters, both methods work fine.

Why I am failing with ad_schedule_proc?

Luis

Luis,

Have you tried to separate command and args?

set command_name "imsld::gsi::${plugin}::check_requisite"
set command_args "-petition_id $petition_id"

ant then

ad_schedule_proc -thread t -once t 0 $command_name $command_args

Collapse
Posted by Luis de la Fuente on
Yes, I tried, but then the result was:

Invalid switch: "-petition_id 1"

Thank you anyway.

By now, I am using ns_thread, but I am curious about why I cannot use the scheduler...

Hi Luis!

Try this:


ad_proc -public test::test {param} {
.... (note the positional parameter)
}

set command_name "test::test"
set command_args 5 # use a list if you want more parameters

ad_schedule_proc -thread t -once t 0 $command_name $command_args

Collapse
Posted by Luis de la Fuente on
Thank you very much for the tip. It really helped!

Cheers,
Luis