Server loop avoidance.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: heatherlaine, Klaus, FourthWorld, kevinmiller

Post Reply
ajperks
Posts: 54
Joined: Sat Sep 06, 2014 3:38 pm

Server loop avoidance.

Post by ajperks » Fri Nov 09, 2018 7:04 pm

From experts advice here on the Forum, and what I have read on the subject, constant cycling of an idle looping server slows down everything else running on that computer.
No doubt someone has a better idea than this, or has invented it already, but what do you think?

My server could just do one pass and complete all its duties. Then run a separate program and exit.
The separate program has a wait state so it is effectively asleep for a time and then checks to see what work has come in for the server to process. In my case, if it is more than X number of files then the program loads and runs the server and terminates.
The wait state can subsequently become shorter or longer based on the flow of incoming files.
I don't know what waste or overhead restarting programs has other than the initialisation of variables, so I look forward to your advice and ideas.
Thank you.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5569
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Server loop avoidance.

Post by dunbarx » Fri Nov 09, 2018 9:29 pm

Hi.

Are you familiar with "sending in time"? It is rarely advisable to use "wait", except in very isolated and well compartmentalized cases.

Check out the "send" command in the dictionary.

If you do use "send", then the overhead and other troubles are likely not overly onerous, at least no more so than the code you are executing.

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4660
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Server loop avoidance.

Post by jacque » Sat Nov 10, 2018 6:39 pm

I agree with Craig, LC has the feature you need built in, so there's no reason to make it more complex. If you do decide to use a second app, you'll have the same problem. The wait command is blocking and can affect the rest of the server as well, so you'd need to use "send" there too.

Rule of thumb is to avoid the wait command for long, ongoing processes. At the very least, use "wait with messages".
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6173
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Server loop avoidance.

Post by FourthWorld » Sat Nov 10, 2018 9:53 pm

Use a request-and-reply protocol like HTTP and you never need to worry about how to handle this on the server.

If you choose HTTP specifically, you also get a vast universe of tooling, docs, and standardization as well.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

ajperks
Posts: 54
Joined: Sat Sep 06, 2014 3:38 pm

Re: Server loop avoidance.

Post by ajperks » Sun Nov 11, 2018 4:44 pm

Thank you all for the well received advice.
I think that is the answer.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”