Results 1 to 4 of 4

Thread: Call Lianja.execute() from a spawned python call

  1. #1

    Call Lianja.execute() from a spawned python call

    Hi Barry,

    I am using the new Lianjarun command - which is working great.

    https://www.lianja.com/doc/index.php/Background_Tasks

    Since I am spawning many simultaneous threads, I am trying to have those threads update a table when they are completed.

    In my python call, I import Lianja a the top, and at the end of the function I am trying to call a vfp function called dispatchminus() like so.
    Lianja.execute("dispatchminus()")
    As I suspeccted might occur, I get a console message dispatchminus.dbo does not exist.

    Is there a way I can specify in a spawned call where I would like a function to run from?

    Thanks

    Herb

  2. #2
    Thinking about this some more, I probably want to have a proc in the database itself or possibly just do an openrecordset from python.

  3. #3
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Hi Herb,

    if your calls are all being made in the same place, an easy way to know when all are done is a) get the spawnpid() of each task, adding them to an array, b) after all the tasks are dispatched iterate the array, testing for activepid(), and when none of them are active, move on.

    If they are being called in different places (however defined), you can use sessionStorage for the pids, and access/test from the common ending point.

    If you have the possibility of multiple servers servicing one "run" of these processes (e.g., microservice calls that load balance), a data-oriented approach where each process registers in the ProcessState table under a master "this is all the same job" ID and then each process also changes its own "lDone" flag to .T. when done is a nice option. In this situation I also typically include tStarted, tHeartbeat, and mErrorInfo, in the hopes of determining the source of any hangs while also knowing when to knock out the main call based on an "it can't be longer than this or we're dead in the water" value set in a convenient place.

    Hank

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,165
    Blog Entries
    22
    Hi Herb,

    You can try specifying —path
    https://www.lianja.com/doc/index.php..._Line_Switches

    You should also be aware that if you are doing this while developing the database and table may be opened exclusively in the app builder so attempting to update it and share data during development may result in some unexpected behavior.
    Last edited by barrymavin; 2018-05-19 at 00:26.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us