Terminate a cfthread doesn't work

97 views
Skip to first unread message

Anders Thulin

unread,
May 26, 2015, 5:51:30 AM5/26/15
to lu...@googlegroups.com
Hi.
I have a problem with a long running thread  want to be able to terminate while its running.
The task uses cfthread to re-schedule it self after performing n number of sub-tasks and can be running for days.
This part works well, but hen trying to terminate the thread from another script i get this error:
there is no thread running with the name [longrunning_thread] at lucee.runtime.tag.ThreadTag.doTerminate(...

To reproduce this error, consider these two scripts:

script 1:
<! this script is running 30 times during a period of 30s ->


<cfparam name="request.count" default="0">

<cfthread name="longrunning_thread" action="run"> 
    <cfscript> 
        sleep(1000); 
        request.count++; 
    </cfscript>

    <cfif request.count LT 30>

        <cfhttp url="[url]/thread.cfm?count=#request.count#" redirect="yes" resolveurl="no" throwonerror="yes" timeout="3600" />

    </cfif> 
</cfthread>


script 2:
<! should terminate the running thread ->
<cfthread name="longrunning_thread" action="terminate" />

Is this a bug or am I doing something wrong?

Jeroen Knoef

unread,
May 26, 2015, 6:04:12 AM5/26/15
to lu...@googlegroups.com
I don't think another thread (script 2) can see or terminate a thread started by script 1, although I must admit I'm not sure.
Anyway, for your use case I would create a gateway. They're quite easy to implement, see this page on the Railo wiki: https://github.com/getrailo/railo/wiki/Create-your-own-Event-Gateway-type

Dominic Watson

unread,
May 26, 2015, 8:09:48 AM5/26/15
to lu...@googlegroups.com
I did some work around managing threads started with CFThread from within other processes. I blogged about it here: http://domwatson.codes/2015/01/manipulating-railo-cfthreads.html. We use it to be able to terminate and monitor scheduled tasks from our own scheduled task manager.

HTH

Dominic

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/e06a0830-28dc-4f37-94bb-1a6d2e041edd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Pixl8 Interactive, 3 Tun Yard, Peardon Street, London
SW8 3HT, United Kingdom

T: +44 [0] 845 260 0726 W: www.pixl8.co.uk E: in...@pixl8.co.uk

Follow us on: Facebook Twitter LinkedIn
CONFIDENTIAL AND PRIVILEGED - This e-mail and any attachment is intended solely for the addressee, is strictly confidential and may also be subject to legal, professional or other privilege or may be protected by work product immunity or other legal rules. If you are not the addressee please do not read, print, re-transmit, store or act in reliance on it or any attachments. Instead, please email it back to the sender and then immediately permanently delete it. Pixl8 Interactive Ltd Registered in England. Registered number: 04336501. Registered office: 8 Spur Road, Cosham, Portsmouth, Hampshire, PO6 3EB
Reply all
Reply to author
Forward
0 new messages