snapshots slowly crashing

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

snapshots slowly crashing

Post by adventuresofgreg » Fri Apr 19, 2013 2:24 pm

Hello: I have a number of instances of the same standalone application running simultaneously, and my snapshot handler isn't working properly. All 16 instances of the SA's will faithfully export their respective .jpg files to my server at a rate of 2 per minute for hours, then slowly, one by one, they will start to fail until by morning time, only half are working, then 12 hours later, 1 or 2 are working, then they will all fail to work. Restarting the script doesn't fix the problem. Restarting the application is the only way to fix this. Perhaps some bit of memory is slowly being filled, or maybe when 2 instances attempt to transmit simultaneously, this is what causes the crash? Any ideas?

Thanks,
Greg

updatesnapshot handler:
on updatesnapshots
if the hilight of button "runsnapshots" is true then
send mouseup to button "snapshot"
send updatesnapshots to me in (field "howmanyminutes" *60) seconds
end if
end updatesnapshots

button "snapshot":
on mouseUp
set the JPEGQuality to JQ
export snapshot from card 1 of stack "G59" to templateX as JPEG
put GT[Cname] & ".jpg" into TMname
put saveplace & TMname into keepPath
libURLSetFTPStopTime 5
libURLftpUpload templateX,keeppath
end mouseup

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: snapshots slowly crashing

Post by Simon » Fri Apr 19, 2013 7:53 pm

Hi Greg,
Look up "unload" in the dictionary. Don't know if it will help but it sounds like something that might help.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: snapshots slowly crashing

Post by adventuresofgreg » Fri Apr 19, 2013 8:58 pm

Simon wrote:Hi Greg,
Look up "unload" in the dictionary. Don't know if it will help but it sounds like something that might help.

Simon
Hi Simon - tried it, and it doesnt help

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: snapshots slowly crashing

Post by sturgis » Fri Apr 19, 2013 10:53 pm

you might look at the pendingmessages and make sure you don't have multiple instances of "updatesnapshots" building up. I don't really see how this could be the case based on your posted code, but its worth a check.

basically something like the following will protect against a slow multiloop buildup. Again, don't see how this could be the case from the code you posted, but maybe there is something else firing in there somewhere that is causing the issue.

Code: Select all

-- off the top of my head so likely imperfect
if lineoffset("updatesnapshots",the pendingmessages) is 0 then send "updatesnapshots" to me in (field "howmanyminuges" * 60) seconds

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: snapshots slowly crashing

Post by adventuresofgreg » Fri Apr 19, 2013 11:37 pm

Yes Simon. I had totally forgotten about PendingMessages. I've used it before. I bet that is what's happening - somewhere, I might be firing off the handler a second time.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: snapshots slowly crashing

Post by Simon » Sat Apr 20, 2013 1:01 am

Thanks sturgis for giving me the credit :D

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: snapshots slowly crashing

Post by adventuresofgreg » Sat Apr 20, 2013 3:22 pm

oops - Sorry simon :-)

I think what 'might' be happening with this script is according to the dictionary, the function libURLftpUpload won't work if a "wait" command is used in a handler while libURLftpupload is being used. If My app is transmitting an order via the API while libURLftpupload is uploading a screen shot to the FTP server, then this could be the cause of the problem. I'm not sure if the result is a total crash and breaking of the libURLftpupload, or simply a failure to upload that instance.

Using 'put' rather than libURLftpupload would resolve this issue, but 'put' is blocking.
Caution! Avoid using the wait command in a handler after executing the libURLftpUpload command. Since the libURLftpUpload command is non-blocking, it may still be running when your handler reaches the wait command.

Post Reply