Skip to main content
Inspiring
November 8, 2023
Answered

AEGP State Management and Long Running Processes

  • November 8, 2023
  • 2 replies
  • 497 views

Any suggestions regarding state management and long-running functions in AEGPs?

If I try to run a function that is long running from the command hook or the idle hook, it cause AE to become unresponsive.

Is this a normal limitation?

Any ideas regarding alternative approaches to long running AEGP processes?

This topic has been closed for replies.
Correct answer Trenton5EC4

Trying to keep this as brief as possible-- but a combined approach using these suggestions worked.

In my plugin I'm embedding a python interpreter, python module, and exposing a "scripting interface" to the user. 
I ended up doing the following:
1. Set Python on a Separate thread from the main AE thread. 
2. Created a "MessageQueue" that can be accessed from both the main and python threads. 

3. For my embedded python module, created classes that wrap MessageQueue calls into the main thread. 

4. Listen for MessageQueue calls in the idleHook.

5. For each call INTO AE from python, there is only one idle hook execution per task. 

Results:
Non-blocking, thread safe interaction between AE and Python!

2 replies

Participant
November 9, 2023
Is this the reason why my updates are not installing?
Community Expert
November 8, 2023

either:

1. break the process down to small pieces and do a series of fast operations on consecutive idle calls.

2. or, launch a new thread and do you process there. during idle calls you check your threads progress, and once it's done you can then finalize whatever interaction you need to make with AE during the idle call using the processed data from the separate thread.

Trenton5EC4AuthorCorrect answer
Inspiring
November 20, 2023

Trying to keep this as brief as possible-- but a combined approach using these suggestions worked.

In my plugin I'm embedding a python interpreter, python module, and exposing a "scripting interface" to the user. 
I ended up doing the following:
1. Set Python on a Separate thread from the main AE thread. 
2. Created a "MessageQueue" that can be accessed from both the main and python threads. 

3. For my embedded python module, created classes that wrap MessageQueue calls into the main thread. 

4. Listen for MessageQueue calls in the idleHook.

5. For each call INTO AE from python, there is only one idle hook execution per task. 

Results:
Non-blocking, thread safe interaction between AE and Python!

Community Expert
November 20, 2023

awsome! love it!