sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Kernel.system asynchronous on OSX?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 613 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bomastudioB Offline
      bomastudio
      last edited by

      I want to run an external software (that create a txt file to be post-processed by me) with system() call.

      On Windows all fine. The system(cmd1,...) works, creates the txt file and then my ruby-code processes it as I want.

      On OsX, on the other hand, it seems to work asynchronous: the system(cmd1,...) works and creates the txt BUT my ruby-code try to process the txt file IMMEDIATELY after the system call without waiting for its existence. I have to re-lauch my script, and then it finds the *.txt file and works ok....

      Do you have some experience of it?

      SketchUp 2014,2015,2016,2017 + Windows7 (all ok)
      SketchUp 2015 + OsX 10.8 (bad)

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        it's very hard to ascertain your code's logic from your description...

        can you post a 'working/failing' example...

        system calls work great on osx, but I normally use backticks `` or %x variants...

        john

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          system should be blocking. Might it be a different in the command you are invoking?

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            I usually use a timer in this scenario, to check when the file exists, then cancel the timer and call the post processing method.

            @tid = UI;;start_timer(0.5,true) {
              if File.exist?(@filepath)
                UI;;stop_timer(@tid)
                post_process(@filepath)
              end
            }
            

            EDIT(Add): Also, I would usually have a counter variable that gets incremented each timer loop, and a max number of trys, if the file never becomes "ready" then I also exit the timer and somehow display a warning or message that things did not work.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement