Announcement

Collapse
No announcement yet.

MvASYNCHRONOUS -- Does anyone have an example

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scot - ScotsScripts.com
    replied
    No, I just searched the code, nothing in the blog module is using mvasync. However, the ganalytics4.mvc module does and it makes a couple calls to to the blog module (if available) to load post or category meta data for blog article tracking.

    I would check to see what version of the ganalytics4 module they are running (if any) and make sure it's up to date. The current public release is 1.016

    https://www.scotsscripts.com/updates...ics4.1.016.zip

    There was an issue with an early version of the ganaltyics4 module that caused performance issues, but not because of mvasync, it had more to do with a bunch of processor consuming category/product lookups or something.

    Also from what I understand there is a bug with mvasync, not sure if it's been fixed yet and I can not remember the details but it can and does cause performance issues through normal mvasync usage.

    Leave a comment:


  • ILoveHostasaurus
    replied
    Originally posted by Scot - ScotsScripts.com View Post
    I use mvasync for anything that might time out since the async process is, from what I've been told, a roughly 60 minute process done in the background. If I need to show progress I create a flat file that has whatever progress data I want and check for it if the user triggers a progress display. Important to know that mvasync won't work with store functions or anything like that unless you initialize the store environment, similar to how you'd need to init the store environment for mvprocessupload.
    Is the Blogger module using mvasync in this manner? Possibly on every runtime request? We've found a store that is having significant performance issues as a result of what appears to be that module and async tasks when there are concurrent requests.

    Leave a comment:


  • dcarver
    replied
    Correct no data can be output from within an MvASYNC task. And yes, scheduled tasks are wrapped in an MvASYNC tag. Since that is the case, you just wouldn't call MvASYNC from your helper function.

    Leave a comment:


  • ids
    replied
    David, Thanks.

    Looks like I have my Async function working.

    For posterity: on this dev store I needed to change the task setting to 0 (zero). Empress doesn't need a restart.

    Two question regarding Async.

    1) Within the tag, looks like MvEval doesn't render the screen? The only way to debug/test results is file output?

    2) And for clarification, Wondering if scheduled tasks are wrapped in an Async? The documentation does mention you can't start an Async within an Async. How does this affect a scheduled task? If my task execution function has an Async, will it run?

    Scott
    Last edited by ids; 03-30-23, 10:11 AM.

    Leave a comment:


  • ids
    replied
    Well, turns out the Miva config has the Async Task value at -1. Is that normal for a mivatest.com dev store?

    Scott

    Leave a comment:


  • dcarver
    replied
    Yes that code seems fine. A better way to handle all of this may be to have your module implement the scheduledtask feature, create X task, and on task execution it could do your MvCALL for you. This way you can have logging for the task being run and any errors that may happen while running it.

    Leave a comment:


  • ids
    replied
    I'm not currently. I guess I wanted some clarification on that too. So I can plan to do that.

    I am trying to get access to view the Empressa config to find out if there is a limitation to Async. The code I posted, was an initial test to find out if it would run at all. Does that code look like it should run if the config will allow any Async tasks?

    Scott

    Leave a comment:


  • dcarver
    replied
    Yeah 120 seconds is a long time. Are you processing the data at all within your MvASYNC tag? Or is that code all that it is doing?

    Leave a comment:


  • ids
    replied
    Thanks, David. I think I am now confused from this whole thread. I am also not understanding why MvCall would be run outside of Async.
    I have a single endpoint that, based on passed parameters, can take just shy of 120 seconds. Was I wrong to conclude that the Async method could allow the MvCall to return the JSON response?

    Here's what I am doing. l.myurl is a confirmed URL I can test with Postman and I get a confirmed JSON response; usually in about 110 seconds. So, I know the URL is solid.
    The prodquery_json is simply the query parameters.
    I am doing this in a UTILS Admin screen/tab right now, but it will be a scheduled task if it matters.

    Code:
    <MvASYNCHRONOUS>
        <MvAssign name="grant_type" value="client_credentials">
        <MvCALL METHOD            = "POST"
                            TIMEOUT         = "85"
                    ACTION          = "{ l.myurl }"
                    CONTENT-TYPE    = "application/json"
                    HEADERS         = "{ 'Authorization: Bearer ' $ l.tokenID $ asciichar( 13 ) $ asciichar( 10 ) }"
                    FIELDS          = "l.prodquery_json">               
                    <MvASSIGN NAME = "l.returnJSON" VALUE = "{ s.callvalue }">
        </MvCALL>
    </MvASYNCHRONOUS>
    Notes: the timeout is the last number I've attempted, with/without Async. I don't know about the grant type so that's another question. But Bill has it in his example and though it was worth keeping.
    And there is a question of using the miva_async_sleep function. Where/How does this function get applied?

    Thanks,

    Scott

    Leave a comment:


  • dcarver
    replied
    It sounds like the site has their maxasynctasks directive set to a relatively low value in their mivavm.conf. There could also be scheduled tasks already running. Using MvASYNC probably isn't the best bet in this case anyway. If your MvCALL failed within it you would have no idea. You should look at alternate solutions such as having the MvCALL outside of the MvASYNC and just waiting for it complete. If it's slow maybe find a way to speed up the response from the server? You could also trigger a scheduled task to run and move your MvCALL into the API functions for scheduled tasks. That would probably better handle all the spawning for you.

    Leave a comment:


  • ids
    replied
    It's the latest version.

    Leave a comment:


  • wmgilligan
    replied
    Hi Scott,
    Do you know what version Empressa is running?

    Leave a comment:


  • ids
    replied
    Unfortunately, I currently don't have access (FTP). And I wouldn't be able to restart Empressa if I needed to change the config.
    I looked at the compiler readme and I don't recall that it explains how many tasks in the miva_async_sleep function. And I am not sure where that function would be placed.

    In this case there are no loops. Just one MvCall to run one endpoint function hoping to run some code to process the response. The endpoint can take time if there is lots of data to gather for the response.

    Scott

    Leave a comment:


  • wmgilligan
    replied
    From the web site: http://www.mivascript.com/item/MvASYNCHRONOUS.html
    "The number of asynchronous tasks allowed, the timeout time for an asynchronous task, and an absolute timeout for miva_async_sleep are all configurable."

    I assume (although I have not run into this issue) that Empressa has a configuration for it. Unfortunately I can no longer locate the Empressa configuration docs.

    Sounds to me like you may be starting to many asynchronous tasks (maybe a loop or something?

    Leave a comment:


  • ids
    replied
    Reviving this thread...hopefully...

    Line 1128: MvASYNCHRONOUS: Maximum number of asynchronous tasks exceeded
    I have no idea how the max number was reached. How can I fix this? What are the conditions for using MvASYNCHRONOUS?

    Notes: In a UTILS module, I am wrapping the MvCall with MvASYNCHRONOUS similar to the example by Bill G earlier in this thread trying to prevent a timeout.
    I see no where in this store that this kind of Async process would be running. I am also not seeing much documentation. Seems like it's straight forward, but, not working.

    Scott

    Leave a comment:

Working...
X