JohnNash

Code executes separate loops at the same time

4 posts in this topic

I've seen some weird behavior in my code (I log almost everything).


 

   While 1
      $WaitingTime = TimerDiff($wtTimer)
      sleep(300)
      $Data = TCPRecv($MainSocket, $MaxLength)
      _FileWriteLog($LogFolder&"info.log", "Wait for answer that Server is ready for step 21")
              

            If $Data = "ByeBye" Then
                                       _FileWriteLog($LogFolder&"info.log", "Server tells me to shutdown")
                                       Terminate()

                 ElseIf $Data = "Step 20 Finished on Server" Then
                                        _FileWriteLog($LogFolder&"info.log", "Server answers it is ready for step 21")
                                        ExitLoop


               ElseIf $WaitingTime>4000 Then
                                         _FileWriteLog($LogFolder&"info.log", "No Answer, we still continue" &$Data)
                                         ExitLoop
            EndIf




   WEnd
   _FileWriteLog($LogFolder&"info.log", "Left the WhileLoop")

 

 

And my logs show this:

 


2016-10-24 00:52:39 : Wait for answer that Server is ready for step 21


2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:40 : Wait for answer that Server is ready for step 21
2016-10-24 00:52:40 : Server answers it is ready for step 21

 

How can this happen? (If there was a "Left the Whileloop" log in between I could imagine it could happen... but now?

I thought AutoIT was singlethreaded...

 

 

 

 

 

Share this post


Link to post
Share on other sites



JohnNash,

AutoIt is single-threaded.

Do you have some form of _Timer_* or Adlib function running elsewhere in the script? That would allow the loop to be interrupted while still running.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites
21 hours ago, JohnNash said:

I log almost everything

:)

Share this post


Link to post
Share on other sites
On 10/25/2016 at 9:51 AM, Melba23 said:

JohnNash,

AutoIt is single-threaded.

Do you have some form of _Timer_* or Adlib function running elsewhere in the script? That would allow the loop to be interrupted while still running.

M23

Yes it seems indeed it has something to do with self-made sleep cycles (while ... wend). Also I ran multiple instances of the client by accident.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Miliardsto
      Autoit ignoring if statement
      By Miliardsto
      My function still making spells and ignoring if statement
      -snip-
      And this function returns true and i see spell is entering
    • skyhigh
      Problem about setting a specific time to run a program
      By skyhigh
      I am working at a script (thanks @Chimp for the help on my previous thread) operating on Firefox, based on two time-set loops that are doing the same operations with some differences.
      Now I need to execute a local video at a determinated hour (between 12 and 4).  
      My question is
      What is the best way to determine a precise hour (hh:mm)? I tried
      While @Hour >= 12 & @MIN >= 00 And @HOUR <= 14 & @MIN < 30 But the loop is being ignored, although in the moment I use only @Min for my tests everything works fine.
      This is the essential - and working - structure of the present script:
      #include <ff.au3> _FFStart() While @MIN >= 00 And @MIN < 30 ; 1st Firefox loop Firefox url loop (contains functions and if conditions) WEnd ;Open a new tab and runs a local video; While @MIN >= 32 And @MIN <= 59 ; 2nd Firefox loop Firefox url loop (contains functions and if conditions) WEnd Thanks in advance
    • Razormaul
      Looping Functions to listview
      By Razormaul
      This is a repost, since the thread was deleted due to database issues. - https://www.autoitscript.com/forum/topic/173518-thread-deleted/
       
      Hello fellow geeks
      I am making a small program for work, a tool with shortcuts and host monitoring.
      The program has several tab and  I need help with the tab called "Servers/Hosts"
      The tab reads hostnames or ip adresses from an ini file and writes them to a listview. You can add or remove hosts, ping, connect with mstsc and delete the whole list. Now...
      Im checking for ip adresses on start of the program, or with a refresh button - so far so good.. It´s working.
      I also have a function to check if a host is online and write it to the listview, but i cant make it work (im not good enough yet) - (ALMOST SOLVED -  Writing a dummyhost e.g. "test" as hostname, gets the status "Online" - im currently working on that )
      This check needs to run every 10 seconds or so, among with the check for ip adresses. But again, (im not good enough yet) - (SOLVED USING AdlibRegister)
      I´ve tried to put the functions in a loop in different places in the script. They either "block" the script or hide it.
      If i can get the loop to work, there is no need for a refresh button. and i want to put the foldercheck in the VIKING tab in a similar loop, displaying a warning instead of having to click a button. (but thats a different question)
      I hope one of you briliant minds can help me along the way:) Thank you for your time.
      Tobias
       
       
      IT-Tools.V13.au3
      Servers.ini