skreien Posted October 8, 2012 Share Posted October 8, 2012 Hey everyone, I have a compiled script that calls an older UDF. It works 99.99% of the time, but every great once in a while it will get stuck. Not sure why or how, but when it does I just want it to exit. Is there a way to set a timer that forces a script to exit after say 2 minutes regardless of its status? Obviously there's many ways to do it external to the script; I'm wondering if there's a way to do it internally? Things are evaluated from the top down, and if the script is stuck on a call and can't proceed, how can I just force it to exit? Thanks! Link to comment Share on other sites More sharing options...
JohnOne Posted October 8, 2012 Share Posted October 8, 2012 AdlibRegister() ? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
clicked Posted October 8, 2012 Share Posted October 8, 2012 I ended up writing a fairly simple "Watchdog" process. I needed this extra complexity because I have a bunch of communicating processes on a network. If something goes wrong, I want them all to shut down and also kill various other processes that have been started. The watchdogs start in either a "master" (for one) or "slave" (for the rest) mode, the slaves connect to the master and the master multicasts a message once a second. If things go silent for 20 seconds then the watchdogs kill everything. Link to comment Share on other sites More sharing options...
skreien Posted October 9, 2012 Author Share Posted October 9, 2012 AdlibRegister looks like it can do exactly what I want. If it's been running for over a minute I can exit the script from there. Looks like a good way to run repetitive checks. I've never seen that function before. Thanks! Link to comment Share on other sites More sharing options...
skreien Posted October 11, 2012 Author Share Posted October 11, 2012 I think I may have found the problem. I had a consolewrite in the app from previous efforts, even though it's not a dos application. It looks like whenever it hit the consolewrite it would just pause. not even the Adlib function could force it to exit. Anyone know if that's expected behavior, or a bug? I would suspect the latter. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 11, 2012 Share Posted October 11, 2012 It's more than likely not a bug with consolewrite, and definitely not expected behavior, that it would pause a script, in fact I've never encountered this in the hundreds of scripts I use consolewrites in. I'd suspect something else in your script, or with the computer it's being used on. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
caleb41610 Posted October 11, 2012 Share Posted October 11, 2012 Fixing the bug would be infinitely better than trying to detect and skip it. I probably can't give much help further than that though. :-| Multi-Connection TCP Server Link to comment Share on other sites More sharing options...
kylomas Posted October 11, 2012 Share Posted October 11, 2012 skreien,Here's a thought, post the script!kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
skreien Posted October 12, 2012 Author Share Posted October 12, 2012 I took the consolewrite out of it to see if that's causing my problem. It only hits it every few days though, so it will probably be a few days before I know. Kylomas: RIght now I'm not posting it because I'm trying to figure out if it's stopping in the call to the UDF, or if it's somewhere in what I've written. Until I know that I don't know what to ask for help with. I've added some code to write a log file as it executes so I can see the last step that executed before it locked up. That's what led me to the consolewrite. That was the very next instruction after the last logfile write. Link to comment Share on other sites More sharing options...
skreien Posted October 12, 2012 Author Share Posted October 12, 2012 Matter of fact, now that I look at it it HAS to be the consolewrite. _WRITELOG("process array console write error") If $aProcessArray[0][3]=-1 Then ConsoleWrite("**CPU Usage** was not able to be obtained this go-around"&@CRLF) _WRITELOG("changed processes") The last thing written to the logfile was "process array console write error". Then it hung for 12 hours until I ended the task. Link to comment Share on other sites More sharing options...
kylomas Posted October 12, 2012 Share Posted October 12, 2012 skreien,I understand that you want to solve this yourself, and, good for you!However, can offer little help without seeing the script.The last thing written to the logfile was "process array console write error". Then it hung for 12 hours until I ended the task.This does NOT mean that this was the last thing that the script was doing, as I'm sure you realize.kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted October 12, 2012 Share Posted October 12, 2012 Opt("TrayIconDebug", 1) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
skreien Posted October 12, 2012 Author Share Posted October 12, 2012 Thanks JohnOne for the idea, but it's being called periodically by another service so I'm not sure I'll be able to see the icon. I've marked the service as interactive so I'll see if it shows up. Link to comment Share on other sites More sharing options...
skreien Posted November 1, 2012 Author Share Posted November 1, 2012 Just wanted to let you know that I traced the problem down to a call to a UDF. There is an updated version to fix other problems so I'm going to give that a shot. Link to comment Share on other sites More sharing options...
kylomas Posted November 1, 2012 Share Posted November 1, 2012 (edited) skreien,Don't know much about networking but ran across this looking for something else. Since your problem seems to be that the script is "hanging" intermittently (which probably means that it is getting an unexpected return from something) this seemed pertinent. IP MulticastThe list of receivers has to exist somewhere. If you use IP Multicast, then the list of receivers is maintained by your networking equipment, usually a router or layer-3 switch. Enable Internet Group Management Protocol (IGMP) in your router, and then the receivers can send IGMP join requests to the router to add themselves to a multicast group. A multicast group is defined as an IP endpoint -- an IP address and a port. In IPv4, addresses 224.0.0.0 through 239.255.255.255 are designated as multicast addresses. To send a datagram to all of the members of the multicast group, just send the datagram once by UDP Unicast to the multicast group endpoint. The router will then forward the datagram to all members of the group.If the receivers are not on the same LAN as you, you probably won't be able to use IP Multicast. IP Multicast will only work if you can know in advance the network route for all receivers who may join your multicast group, and make sure that all the network equipment is configured properly.You can't use IP Multicast over the internet.You may want to re-visit everywhere that you expect a return value (or the absence of one).Good Luck,kylomasEdit: misread previous post Edited November 1, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now