Have you tried creating a task thread instead? Then timeouts and
application tracking are unneeded.
Status and errors show up in the tasks section of the admin - until the
thread completes successfully.
The only time you’d need to set app vars is for users to be able to track
progress.
One minor thing with task threads: put all the input vars needed by the
thread into the attribute collection used to call it. Task threads are not
tied to current page/request/session etc.
I’ve noticed that task threads also do a better job of maintaining good
server performance under load.On Wednesday, November 4, 2015 at 2:37:02 PM UTC-5, eddie b wrote:
I’m looking to write a background process that runs within the application
context. I figured the best way to do this would be to use cfthread to
create a new run, and loop within that, checking for a control variable on
each iteration (in case it needs to be stopped). However, the thread keeps
dying due to the request time out setting. I can increase or decrease this
using cfsetting within the cfthread tag, but I cannot disable it (setting
it to 0 just makes the timeout happen almost instantly). Increasing the
timeout to something very large won’t work, as I’d like this thread to
ideally run indefinitely.
Is there any way to prevent the timeout from occurring at all? I
understand this is a potentially dangerous route to go down, as it could
lead to numerous infinitely running threads that could only be killed by
restarting Lucee if I’m not careful. I have looked into both the
EventGateway and Task Scheduler, but neither quite works for what I want to
do, although I haven’t completely ruled either out yet.
Below is what I’m seeing in thread.log
“ERROR”,“cfthread-8”,“11/04/2015”,“14:24:49”,“”,"cfthread-8;java.lang.ThreadDeath;java.lang.ThreadDeath
at java.lang.Thread.stop(Thread.java:850)
at lucee.commons.io.StopThread.run(SystemUtil.java:1068)
"
And below is requesttimeout.log
“ERROR”,“Thread-6”,“11/04/2015”,“14:24:49”,“controler”,“stop thread (6)
because run into a timeout path:
D:\lucee\lucee-4.5.1.024-express\webapps\ROOT\index.cfm.;java.lang.Throwable;java.lang.Throwable
at java.lang.Thread.sleep(Native Method)
at lucee.runtime.functions.system.Sleep.call(Sleep.java:28)
at
index_cfm$cf.threadCall(D:\lucee\lucee-4.5.1.024-express\webapps\ROOT\index.cfm:17)
at lucee.runtime.thread.ChildThreadImpl.execute(ChildThreadImpl.java:199)
at lucee.runtime.thread.ChildThreadImpl.run(ChildThreadImpl.java:148)
"
“ERROR”,“Thread-23”,“11/04/2015”,“14:24:49”,”","Thread.stop(Throwable) is
not supported by this JVM and failed with
UnsupportedOperationException;java.lang.Throwable;java.lang.Throwable
at java.lang.Thread.sleep(Native Method)
at lucee.runtime.functions.system.Sleep.call(Sleep.java:28)
at
index_cfm$cf.threadCall(D:\lucee\lucee-4.5.1.024-express\webapps\ROOT\index.cfm:17)
at lucee.runtime.thread.ChildThreadImpl.execute(ChildThreadImpl.java:199)
at lucee.runtime.thread.ChildThreadImpl.run(ChildThreadImpl.java:148)
"
On Wednesday, November 4, 2015 at 2:37:02 PM UTC-5, eddie b wrote:
I’m looking to write a background process that runs within the application
context. I figured the best way to do this would be to use cfthread to
create a new run, and loop within that, checking for a control variable on
each iteration (in case it needs to be stopped). However, the thread keeps
dying due to the request time out setting. I can increase or decrease this
using cfsetting within the cfthread tag, but I cannot disable it (setting
it to 0 just makes the timeout happen almost instantly). Increasing the
timeout to something very large won’t work, as I’d like this thread to
ideally run indefinitely.
Is there any way to prevent the timeout from occurring at all? I
understand this is a potentially dangerous route to go down, as it could
lead to numerous infinitely running threads that could only be killed by
restarting Lucee if I’m not careful. I have looked into both the
EventGateway and Task Scheduler, but neither quite works for what I want to
do, although I haven’t completely ruled either out yet.
Below is what I’m seeing in thread.log
“ERROR”,“cfthread-8”,“11/04/2015”,“14:24:49”,“”,"cfthread-8;java.lang.ThreadDeath;java.lang.ThreadDeath
at java.lang.Thread.stop(Thread.java:850)
at lucee.commons.io.StopThread.run(SystemUtil.java:1068)
"
And below is requesttimeout.log
“ERROR”,“Thread-6”,“11/04/2015”,“14:24:49”,“controler”,“stop thread (6)
because run into a timeout path:
D:\lucee\lucee-4.5.1.024-express\webapps\ROOT\index.cfm.;java.lang.Throwable;java.lang.Throwable
at java.lang.Thread.sleep(Native Method)
at lucee.runtime.functions.system.Sleep.call(Sleep.java:28)
at
index_cfm$cf.threadCall(D:\lucee\lucee-4.5.1.024-express\webapps\ROOT\index.cfm:17)
at lucee.runtime.thread.ChildThreadImpl.execute(ChildThreadImpl.java:199)
at lucee.runtime.thread.ChildThreadImpl.run(ChildThreadImpl.java:148)
"
“ERROR”,“Thread-23”,“11/04/2015”,“14:24:49”,”","Thread.stop(Throwable) is
not supported by this JVM and failed with
UnsupportedOperationException;java.lang.Throwable;java.lang.Throwable
at java.lang.Thread.sleep(Native Method)
at lucee.runtime.functions.system.Sleep.call(Sleep.java:28)
at
index_cfm$cf.threadCall(D:\lucee\lucee-4.5.1.024-express\webapps\ROOT\index.cfm:17)
at lucee.runtime.thread.ChildThreadImpl.execute(ChildThreadImpl.java:199)
at lucee.runtime.thread.ChildThreadImpl.run(ChildThreadImpl.java:148)
"